Input

Touch gestures, key events, and text input

findAndTap(objectName, options?)

Finds an object on screen by image matching and taps its center.

ParameterTypeDefaultDescription
objectNamestringName of the UI object defined in the visual editor
options.thresholdnumber0.70Minimum match confidence 0.0–1.0
options.matchTimeoutnumberMaximum milliseconds to spend on the pyramid search. The search stops early after the allotted time; any scales already completed are still used. Omit for no limit.
options.randomizeClickRadiusnumberOverrides global click randomization settings with a specific radius.
options.randomizeDelay[number, number]Randomized delay before tap (e.g. [50, 150])

Returns booleantrue if the object was found and tapped

findAndTap("play_button");
findAndTap("enemy_icon", { threshold: 0.85 });                    // stricter match
findAndTap("enemy_icon", { matchTimeout: 200 });                  // stop search after 200 ms
findAndTap("enemy_icon", { threshold: 0.85, matchTimeout: 150 });

findAndLongPress(objectName, options?)

Finds an object on screen by image matching and holds a finger at its center.

ParameterTypeDefaultDescription
objectNamestringName of the UI object defined in the visual editor
options.durationnumber500Hold duration in milliseconds
options.thresholdnumber0.70Minimum match confidence 0.0–1.0
options.matchTimeoutnumberMaximum milliseconds to spend on the pyramid search. The search stops early after the allotted time; any scales already completed are still used. Omit for no limit.
options.randomizeClickRadiusnumberOverrides global click randomization settings with a specific radius.
options.randomizeDelay[number, number]Randomized delay before long press (e.g. [50, 150])

Returns booleantrue if the object was found and the long press was performed

findAndLongPress("item_slot");                              // 500 ms hold
findAndLongPress("item_slot", { duration: 1500 });          // 1.5 s hold
findAndLongPress("item_slot", { duration: 1000, threshold: 0.85 });
findAndLongPress("item_slot", { duration: 1000, matchTimeout: 200 }); // cap pyramid search at 200 ms

tapAt(objectName)

tapAt(x, y)

Taps at a known location without performing image matching. Pass an object name to tap its stored center, or pass coordinates to tap at a specific position on screen.

Marketplace macros: raw coordinates (tapAt(x, y), swipe, longPress) are tied to your device's pixel dimensions and will land in the wrong place on other screen sizes. For macros you intend to share, use image-matching functions (findAndTap, findObject(...).tap()) or named objects (tapAt("name")) instead — these are resolution-independent.
ParameterTypeDescription
objectNamestringName of the UI object; taps its fixed bounding-box center
x, ynumberScreen coordinates in current device pixels
options.randomizeClickRadiusnumberJitter radius (px) for this call, used in place of the size-based default. Requires click randomization to be enabled — it's off by default and can only be enabled in the app settings, not from a script. This sets the radius, it does not turn randomization on.
options.randomizeDelay[number, number]Randomized delay before tap (e.g. [50, 150])

Returns booleantrue if the tap was dispatched; false if the named object was not found or the gesture could not be dispatched

tapAt("menu_icon");       // tap stored center of object
tapAt(540, 960);          // tap at raw coordinates

swipe(x1, y1, x2, y2, options?)

Performs a swipe gesture from one point to another.

ParameterTypeDefaultDescription
x1, y1numberStart coordinates in current device pixels
x2, y2numberEnd coordinates in current device pixels
options.durationnumber300Swipe duration in milliseconds
options.randomizeClickRadiusnumberOverrides global click randomization settings with a specific radius.
options.randomizeDelay[number, number]Randomized delay before swipe (e.g. [50, 150])

Returns booleantrue if the swipe was dispatched; false if the accessibility service is inactive or the gesture was cancelled by the system

swipe(100, 500, 100, 200);                    // default duration
swipe(100, 500, 100, 200, { duration: 400 }); // custom duration

longPress(objectName, options?)

longPress(x, y, options?)

Holds a finger at a known location without performing image matching. Pass an object name to long-press its stored center (mirroring tapAt(objectName)), or pass coordinates to press a specific position on screen.

ParameterTypeDefaultDescription
objectNamestringName of the UI object; presses its fixed bounding-box center
x, ynumberCoordinates to press in current device pixels
options.durationnumber500Hold duration in milliseconds
options.randomizeClickRadiusnumberOverrides global click randomization settings with a specific radius.
options.randomizeDelay[number, number]Randomized delay before long press (e.g. [50, 150])

Returns booleantrue if the long press was dispatched; false if the named object was not found, the accessibility service is inactive, or the gesture was cancelled by the system

longPress("menu_icon");                  // hold stored center of object
longPress(300, 600);                     // default duration
longPress(300, 600, { duration: 1000 }); // custom duration

multiLongPress(positions, options?)

Holds multiple fingers at the given coordinates simultaneously. Each finger can have its own hold duration by passing a third element in its coordinate tuple; fingers without an individual duration fall back to options.duration.

ParameterTypeDefaultDescription
positionsArray<[x, y, duration?]>Array of [x, y] or [x, y, duration] tuples
options.durationnumber500Fallback hold duration in ms for fingers that do not specify their own
options.randomizeClickRadiusnumberJitter radius (px) applied to each finger's position. Requires click randomization to be enabled.
options.randomizeDelay[number, number]Randomized delay before the gesture (e.g. [50, 150])

Returns booleantrue if the gesture was dispatched (false if no valid positions were supplied or it was cancelled); blocks until the longest finger is released

// All fingers held for the same duration
multiLongPress([[100, 200], [300, 400]], { duration: 1000 });

// Each finger with its own duration (no options needed)
multiLongPress([[500, 200, 3000], [500, 400, 7000], [500, 600, 10000]]);

// Mixed — third finger falls back to options.duration
multiLongPress([[500, 200, 3000], [500, 400]], { duration: 5000 });
Why not three separate spawnThread + longPress calls? Android's AccessibilityService only allows one active gesture at a time. Dispatching a second gesture cancels the first, so three concurrent longPress calls will cancel each other in a rapid loop, causing visible flickering. multiLongPress packs all fingers into a single gesture dispatch, which is the only reliable way to hold multiple touch points simultaneously.

multiSwipe(fingers, options?)

Performs multiple synchronized swipe gestures simultaneously. All fingers begin and end their swipes at the same time.

ParameterTypeDefaultDescription
fingersArray<[x1, y1, x2, y2]>Array of swipe coordinate tuples
options.durationnumber300Duration of the entire multi-swipe gesture in ms
options.randomizeClickRadiusnumberRadius (px) of the shared jitter offset applied to all fingers. Requires click randomization to be enabled — it's off by default and can only be enabled in the app settings, not from a script. This sets the radius, it does not turn randomization on.
options.randomizeDelay[number, number]Randomized delay before the gesture (e.g. [50, 150])

Returns booleantrue if the gesture was dispatched; false if no valid fingers were supplied or it was cancelled

// Swipe with two fingers simultaneously
multiSwipe([[100, 500, 100, 200], [300, 500, 300, 200]], { duration: 400 });
Note: when click randomization is enabled, one shared jitter offset is applied to every finger so the inter-finger geometry (e.g. a two-finger pan) is preserved — the fingers are not jittered independently.

performGesture(gestureName)

Executes a complex, pre-recorded gesture sequence defined in the visual editor.

ParameterTypeDescription
gestureNamestringName of the recorded gesture

Returns booleantrue if the gesture was found and dispatched

performGesture("complex_unlock_pattern");

pinch(cx, cy, amount, options?)

Performs a zoom or pinch gesture around a center point.

ParameterTypeDefaultDescription
cx, cynumberCenter of the gesture in current device pixels
amountnumberPositive = zoom in, negative = zoom out (pixel span delta)
options.durationnumber300Gesture duration in milliseconds
options.randomizeClickRadiusnumberJitter radius (px) for the center, used in place of the size-based default. Requires click randomization to be enabled — it's off by default and can only be enabled in the app settings, not from a script. This sets the radius, it does not turn randomization on.
options.randomizeDelay[number, number]Randomized delay before the gesture (e.g. [50, 150])

Returns booleantrue if the gesture was dispatched; false if the accessibility service is inactive or the gesture was cancelled by the system

pinch(540, 960, 200);                     // zoom in, default duration
pinch(540, 960, -200, { duration: 400 }); // zoom out, custom duration
Note: when click randomization is enabled, the center is jittered (use randomizeClickRadius to set the radius) and the finger span and duration are varied slightly so repeated pinches aren't identical. With randomization off, the gesture centers on the exact cx, cy with the exact duration you pass.

keyEvent(keyCode)

Sends an Android key event. Use the built-in KeyCode object for readable named constants instead of raw numbers.

ParameterTypeDescription
keyCodenumberAndroid KeyEvent constant. See the KeyCode reference below.

Returns booleantrue if the key event was dispatched; false if the keycode isn't supported on the current input backend (some keycodes require Shizuku)

keyEvent(KeyCode.BACK);   // press Back
keyEvent(KeyCode.HOME);   // press Home
keyEvent(KeyCode.ENTER);  // confirm input

KeyCode

A frozen object of named Android key code constants. Prevents typos and makes scripts self-documenting.

ConstantValueDescription
KeyCode.HOME3Home button
KeyCode.BACK4Back button
KeyCode.DPAD_UP19D-pad up
KeyCode.DPAD_DOWN20D-pad down
KeyCode.DPAD_LEFT21D-pad left
KeyCode.DPAD_RIGHT22D-pad right
KeyCode.DPAD_CENTER23D-pad center / confirm
KeyCode.VOLUME_UP24Volume up
KeyCode.VOLUME_DOWN25Volume down
KeyCode.POWER26Power button
KeyCode.TAB61Tab key
KeyCode.SPACE62Space key
KeyCode.ENTER66Enter / confirm
KeyCode.DEL67Backspace
KeyCode.ESCAPE111Escape key
KeyCode.FORWARD_DEL112Delete (forward)
KeyCode.APP_SWITCH187Recents / app switcher

inputText(text)

Types text into the currently focused field.

ParameterTypeDescription
textstringText to type

Returns booleantrue if the text was dispatched; false if no input field is focused

inputText("Hello world");