Utilities

Logging, screen info, flow control, and macro invocation

print(...values)

Displays a message in the macro status / log output. Accepts any number of arguments — they are converted to strings and joined with a space, matching console.log behaviour.

ParameterTypeDescription
valuesanyOne or more values to display

Returns void

print("counter:", getGlobalVar("counter"));
print("pos:", pos.x, pos.y);
print("done");

getScreenSize()

Returns the physical screen dimensions in pixels. Useful for writing device-agnostic scripts that position elements relative to screen size.

Returns {w: number, h: number} — width and height of the screen in physical pixels

var screen = getScreenSize();
tapAt(screen.w / 2, screen.h / 2); // tap the center

// Relative positioning
tapAt(screen.w * 0.1, screen.h * 0.9); // bottom-left area

exit()

Immediately stops the macro. Equivalent to the user pressing Stop — the run is marked as completed, not as an error.

Returns void — never returns; execution halts at this call

if (getGlobalVar("retries") >= 5) {
  print("giving up");
  exit();
}

// Also useful as a clean stop at the end of a conditional branch
if (ocr("status") === "done") exit();

callMacro(id)

Runs another macro synchronously by its ID. Blocks until the called macro finishes. Has no effect if the macro ID does not exist.

ParameterTypeDescription
idstringThe macro's internal ID or name

Returns void

callMacro("abc-123-def");