Search | Region():find(Asset.image("name"):mScore(0.8), {engine="balanced_image"})New·v1.0.51local hit = Region():find(Asset.image("icon"):transparent(), {engine="pixel_exact_image", tol=16})
if hit then System.log(tostring(hit:getEngine()) .. " " .. hit:getAngle()) endNew engine keys: gray_image, pixel_exact_image (tol 0–64), orientation_image (experimental), and sift_image; Lua can also select auto_image, silhouette_image, and rotation_image (experimental; angle, angleStep). :transparent() ignores the template’s transparent pixels; getEngine() reports the engine that searched and getAngle() the rotation it found. | Searches the region for a template image; mScore is the match threshold (0–1) and engine selects the scan engine. |
Search | Region():find(Asset.text("target"), {ocrScript="latin"})
Region():readPlain({ocrScript="latin"}) -- OCR find/replace | OCR-searches the region for the text; with OCR find/replace set, it also reads the region and writes the cleaned text to the Save Read Value variable. |
Search | Region():find(Asset.color("#RRGGBB"):mScore(score)) | Searches for a specific color in the region. |
Search | compare repeated Region():find(Asset.color("#RRGGBB")) positions | Tracks whether a color shifts position. |
Search | (Visual Builder only: combines multiple IMAGE/TEXT/COLOR targets into one decision block) | Combines multiple IMAGE/TEXT/COLOR targets into one decision block. |
Search | (Visual Builder only: locks onto one IMAGE/TEXT/COLOR match, then tracks nearest continuation until lost-frame limit) | Locks onto one image/text/color match and tracks the nearest continuation candidate until the lost-frame limit is reached. |
Search | VisualTarget.profile/refresh/step/snapshot/reset/click/swipeToward | Acquires, tracks, and reacquires a multi-view target fully on-device, publishing bounds, centre, view, engine, score, velocity, loss, and error outputs. |
Search | local r = Region():agentDetect(macroScopeId, referenceSetId, options); if r.status == "found" then click(r.targets[r.selected].clickMatch) end | Finds and tracks targets that visually resemble examples marked in reference screenshots, offline; returns status (found/not_found/error), a typed code and a target table, and never taps by itself. The no-code block revalidates the target on a fresh frame right before tapping. |
Search | local raw = Region():readAsString(param, "")
local value = Num.parseOcr(raw, 0) | Reads the region with OCR and converts the text to a number; an unreadable value becomes 0. |
Search | local text = Region():readAsString(param, ""); local r = AI.ask(prompt .. text, providerId) | Reads a region via OCR, then turns the text into a decision with AI.ask. |
Search | Capture.regionToBase64(region, "jpeg", 60) + AI.askVision(prompt, image, providerId, "image/jpeg", nil, timeoutMs) | AI mode uses a vision request; local mode samples Color.getAllScreen. true/false/unknown/error, retry, confidence and target rules are additional Lua logic; use generated code for the full equivalent. |
Action | local result = Navigation.run({profileId="saved-profile-uuid", routeId="saved-route-uuid", routeType="one_way", controlMode="strict", timeoutMs=120000}) | Use IDs from a saved setup and route in this macro; do not execute the example labels verbatim. Runs feedback-controlled movement with measured local calibration; returns state/lastFailure and typed measurements. headingKnown is false for an unknown heading. |
Action | if Navigation.stop() ~= true then error("NAVIGATION_RELEASE_UNCONFIRMED") end | Place it before screen actions in a Scan group while moving. It ends this macro’s journey and blocks the next action until joystick release is confirmed; the journey does not resume automatically. |
Action | click(Point(x, y), {repeatCount=1, holdMs=0})
click(Region():find(...), param) | Taps a point or a match; supports repeat and hold parameters. |
Action | swipe({GesturePoint(start, 0, 0), GesturePoint(end, 0, 300)}) | Swipe between two points. |
Action | Replay.start(); Replay.stop()
Replay.play(name, {repeatCount=1, waitNextMs=0, randomRadius=0, speedMultiplier=1}) | Starts or stops a recording, or plays a saved touch recording with Replay.play (repeat, wait, random radius and speed). |
Action | for i = 1, maxRepeats do
if not Region():find(Asset.image("anchor")) then break end
Replay.play(name, {repeatCount=1})
wait(waitMs)
end | Plays the recording with Replay.play while its image anchor stays on screen; the anchor is searched again before every repetition, and the loop stops once it disappears. |
Action | System.toast("text") | Shows a short on-screen message (toast); {{ expression }} templates are resolved. |
Action | Request(url):setContentType("application/json"):setBody(JSON.stringify({content=message})):post() (Discord/Telegram/Generic preset) | Sends a notification to a Discord, Telegram, or generic webhook over HTTPS POST; built on the HTTP_POST infrastructure with no new Lua API. |
Action | System.playMedia(asset) | Plays a sound asset. |
Action | Panel.show() / Panel.hide() / Panel.spin() / Panel.close() / Panel.move(x, y) / Panel.setOpacity(0.6) | Shows, hides, or minimizes the control panel, opens the helper panel (spin), stops and closes it, moves it, or sets its opacity from 0 to 1. To write text on screen, see the HUD OVERLAY row. |
Action | local hud = Hud(x,y,w,h,false); hud:setText("text"); hud:show(); hud:setText("updated") | Writes text/state into the on-screen HUD. |
Action | local id = System.setTimeout(ms, fn) -- or System.setInterval(ms, fn)
System.clearTimeout(id) -- or System.clearInterval(id) | Calls the chosen block group once after a delay (timeout) or repeatedly at an interval (interval); the same block’s clear action cancels the timer by its id. |
Touch | New·v1.0.51 Touch.laneAdd(from, to, legMs, legs, turn, finish); Touch.laneStart(tag, background, maxRunMs); Touch.laneStatus(tag) | Stages fingers as lanes and starts them together: a stationary hold, a back-and-forth or restarting swipe, optionally running in the background. Touch.laneError() returns the failure code. Version 1.0.50 and earlier generate this block as Touch.down(point, finger) plus Touch.dispatch(). |
Touch | Touch.breakAll() New·v1.0.51Touch.breakAll() -- also lifts background lanes
Touch.laneRelease("hold", 0) -- lifts only the lane tagged "hold"It also stops touch lanes running in the background. To lift a single lane, use Touch.laneRelease(tag, 0); Touch.laneRelease("", 0) lifts every lane. | Lifts every held finger and resets the touch state. |
Touch | MultiGestureBuilder():add({GesturePoint(a1, 0, 0), GesturePoint(a2, 0, 500)}):add({GesturePoint(b1, 0, 0), GesturePoint(b2, 0, 500)}):build():go() | Each add() adds one finger path; build():go() sends two or more paths at the same time as a single multi-finger gesture. |
Flow | wait(ms) | Pauses for a duration. |
Flow | local ok = (a and b) or c | Combines compare conditions with AND/OR into one boolean result. |
Flow | if cond then ... else ... end | Runs the TRUE or FALSE branch based on a condition. |
Flow | -- Compare values
if a == b then ... else ... end
-- Compare screen regions
local ref = Capture.regionToBase64(referenceRegion, "png", 100)
-- the block turns ref into an in-memory image template (never saved to the gallery)
local hit = targetRegion:find(referenceTemplate) | “Compare values” maps to the Lua if-else construct. “Compare screen regions” captures the first region as a reference (kept only in runtime memory, never added to the gallery), searches the target regions for a similar image with any/all logic, and hands the matched target to click, swipe, and touch blocks in the True branch. This mode cannot run inside a pure condition list. |
Flow | generated _mhM measurements + Lua geometry/conditions | Evaluates measurements published by earlier blocks and produces direction, angle, distance, and status outputs. |
Flow | for i, v in ipairs(t) do ... end | Iterates over a collection. |
Flow | if v == 1 then ... elseif v == 2 then ... else ... end | Lua has no native switch; equivalent via if/elseif chain. |
Flow | local ok, err = pcall(function() ... end) | Error catching via pcall. |
Flow | return value | Returns a value from the enclosing function. |
Flow | local function name() ... end | A callable block group (function). |
Flow | No direct Lua call; see the note. | Generates Lua state logic that selects one workflow per invocation: sequential, random, or advancing on the invocation after a marker completes. It is not a standalone runtime API call. |
Flow | No direct Lua call; see the note. | Generates two lanes and target checkpoints at safe action boundaries as ordinary Lua flow; there is no separate global API. Nested group progress is preserved. |
System | No direct Lua call; see the note. | Generates Lua flow that repeats preceding blocks in the same sequence by count or duration; there is no separate global API. Choose the start boundary, first-pass handling and repeat interval in the block settings. |
Flow | local gate = PhaseGate.create(options); PhaseGate.next(gate); PhaseGate.status(gate); PhaseGate.reset(gate) | Selects True/False by visit or elapsed-time limits; it does not create a loop. Retain the handle between visits. Expiry does not interrupt an action already running. |
Flow | name(arg1, arg2) | Calls a defined group. |
Flow | Lua state + conditions + group functions | State transitions, timeouts and recovery group calls are generated Lua and can be extended in the code editor. |
Flow | Macro.run(target, params)
local result = Macro.runWait(target, params, timeoutMs) | Starts another saved macro; in wait mode it stores the outcome in a variable. |
Flow | if not (cond) then error("message") end | Raises an error when the condition fails; Try/Catch catches it, and an uncaught error goes to ERROR_HANDLER when present or stops the macro. |
Flow | -- single-line
--[[ block ]] | Inline note that does not execute. |
Flow | local result = Setting.builder():add("confirm", Checkbox(false, "Confirm")):add("name", EditText("", 1, "Name", "Enter your name")):setPositiveButton("OK"):setNegativeButton("Cancel"):build():show() | Shows a dialog with checkbox, text input, and selection fields; show() returns the field values in a table keyed by field id (result.confirm, result.name). |
Flow | x = (value) -- macro variable | Stores a value or expression result in a macro variable; for a value that persists between runs, use KV_SET. |
Flow | local r = expression -- plain Lua arithmetic | Computes an arithmetic or variable-based expression. |
Flow | Math.randomRange(min, max) | Generates a random whole number between min and max, inclusive. |
System | break | Exits the enclosing loop. |
System | goto continue -- the ::continue:: label sits at the end of the loop body | Lua has no continue keyword; emulated via goto + label. |
System | Metrics.summary(); Metrics.enable(); Metrics.disable(); Metrics.reset() | Manages runtime metrics with summary, enable, disable, and reset actions. |
System | System.home() / System.back() / System.openApp(package) / System.openUrl(url) / System.sendIntent(action, package) ... | Safe wrapper over system calls; Send Intent emits System.sendIntent(action, package?) and still passes runtime allowlist policy. |
System | System.log("text")
System.log("Count: " .. tostring(count)) -- LOG "Count: {{ count }}" | Writes a message to the macro log; {{ expression }} templates are resolved, Lua concatenation outside a template is printed as written. |
System | local res = Request(url):get(); local code, body = res:getResponseCode(), res:getData() | Sends an HTTPS GET request; read the status code with getResponseCode() and the response body with getData(). |
System | Request(url):setBody(body):post() | Sends a POST request. |
System | Request(url):setBody(body):put() | Sends a PUT request. |
System | Request(url):setHeader(...):setBody(...):post() | Fully parameterized HTTP request. |
System | local r = WebSocket.exchange(url, message, maxMessages, timeoutMs, headers)
-- r.ok, r.first, r.messages, r.count, r.error | One-shot exchange: connects to a wss:// address, sends the message, waits for the requested number of replies or the timeout, then closes; it is not a permanent subscription. For a connection that stays open, use the object returned by WebSocket.connect(url) in code with ws:on(...), ws:send(...), and ws:receive(...). |
System | (runs your Lua as written) | Embeds a raw Lua block inside the visual chain. |
Data | local list = {"a", "b", "c"} | Stores line- or comma-separated values as a list variable. |
Data | Str.toUpperCase(s) / Str.substring(s, i, j) / Str.replace(s, a, b) / Str.split(s, sep) ... | String operations (lower, upper, replace, etc.). |
Data | Regex.match("h.*o", "hello")
Regex.matchAll(pattern, s) | Matches with Java-syntax regex (not Lua patterns). |
Data | DateTime.nowMs()
DateTime.format(DateTime.nowMs(), "yyyy-MM-dd") | Reads current date or timestamp. |
Data | TimeSpan.fromSeconds(5)
TimeSpan.fromMinutes(2):totalMillis() | Builds a duration from a value and a unit (ms, seconds, minutes, hours, days) and returns the duration or its total milliseconds. |
Data | local sw = Stopwatch(); sw:start(); ... local dt = sw:elapsedMs() | Measures elapsed time. |
Data | KV.get("key") | Reads from the persistent key/value store. |
Data | KV.set("key", value) | Writes to the persistent key/value store. |
Data | Clipboard.paste() | Reads the system clipboard; Clipboard.get() returns the same value. |
Data | Clipboard.copy("text") | Writes to the system clipboard. |
Data | File.readText("path") -- sandboxed path | Sandboxed file read. |
Data | File.writeText("path", "content")
File.appendText("path", "content") -- append mode | Sandboxed file write. |
Data | File.delete("path") | Deletes a sandboxed file or folder. |
Data | JSON.parse("...") | Parses JSON text into a Lua table. |
Data | Collection.put("items", "id", {name="value"}); Collection.list("items") | Manages an ordered document collection. |
Data | local m = Map(); m:set("key", "value"); m:get("key") | Manages a key/value map. |
Advanced | while cond do ... end | Repeats while a condition holds. |
Advanced | repeat ... until cond | Repeats until a condition holds (at least once). |
Advanced | local ok, err = pcall(function() ... end) -- the whole main flow
if not ok then System.log("Error: " .. tostring(err)) end -- Error Action: Log | Wraps the whole main flow in one pcall; an uncaught error goes to the Error Variable (default errorMessage) and the chosen Error Action runs once: Log, Notify, Stop, Continue or Custom (Recovery Actions). The macro then ends. |
Advanced | while DateTime.nowMs() < deadline do wait(interval) end | Waits until a deadline. |
Advanced | local result = Agent.run("saved_agent_block_id") | Runs a separately approved routine/plan of a saved Agent block in this macro with macro-start consent. Use a literal block id; returns ok/outcome/taps/detail/kind. Emulator/API tests are not physical-device or game-success proof. |