Skip to main content

The Steps engine

An action whose engine is Steps is a TOML list of [[steps]] tables instead of text. It calls the same builtins and follows the same value and truthiness rules. The differences:

  • Each step has a unique integer id and an op: call (fn, args), set (local plus a value, or a call = { fn, args }), if, goto, end, repeat/end_repeat, exit_repeat, else/end_if.

  • An if either jumps by id (then_goto/else_goto) or, without those, opens a block closed by end_if.

  • repeat takes exactly one of times, while or until.

  • A condition is exactly one of: a builtin call (fn/args), value (truthiness), or compare ("==", "!=", "<", "<=", ">", ">=") with left/right. Add not = true to invert it.

  • A string argument starting with $ reads a variable ("$target"). Everything else is a literal whose kind is its TOML kind, and that kind must match the parameter exactly, as in Script.

  • { const = "VirtualKey.MediaPlayPause" } is a named constant, replaced by its number when the steps compile, as in Script. A plain string spelled like one, such as "VirtualKey.F5", stays text.

  • { fn = "MouseGetCursorX" }, a table holding only fn, is the result of a builtin that takes no arguments. It is accepted wherever a value is:

    • a call's args: args = [{ fn = "WindowGetActive" }]
    • a condition's left/right: left = { fn = "ContextGetPointCount" }, right = 20
    • a condition's value: value = { fn = "EngineIsSafeMode" }
    • a repeat's times: times = { fn = "FolderWatchGetCount" }
    • a set step's value: value = { fn = "UtilityGetTickCount" }

    It takes no args. For a builtin that needs arguments, set its result into a variable first and pass "$name".

  • There are no operator expressions. Arithmetic and string building need a Script action.

[[steps]]
id = 1
op = "set"
local = "target"
call = { fn = "WindowGetActive", args = [] }

[[steps]]
id = 2
op = "if"
condition = { fn = "WindowContainsTitle", args = ["$target", "Notepad"] }

[[steps]]
id = 3
op = "call"
fn = "WindowMaximize"
args = ["$target"]

[[steps]]
id = 4
op = "end_if"