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, getPosition(...).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.randomizeClickRadiusnumberOverrides global click randomization settings with a specific radius.
options.randomizeDelay[number, number]Randomized delay before tap (e.g. [50, 150])

Returns void

tapAt("menu_icon");       // tap stored center of object
tapAt(540, 960);          // tap at exact 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 void

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

longPress(x, y, options?)

Holds a finger at the given coordinates.

ParameterTypeDefaultDescription
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 void

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

Returns void — 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 });
Note: Randomization options (randomizeClickRadius and randomizeDelay) are not supported for this method.
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.

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

Returns void

pinch(540, 960, 200);                     // zoom in, default duration
pinch(540, 960, -200, { duration: 400 }); // zoom out, custom duration
Note: Randomization options (randomizeClickRadius and randomizeDelay) are not supported for this method.

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 void

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 void

inputText("Hello world");