Input
Touch gestures, key events, and text input
findAndTap(objectName, options?)
Finds an object on screen by image matching and taps its center.
| Parameter | Type | Default | Description |
|---|---|---|---|
objectName | string | — | Name of the UI object defined in the visual editor |
options.threshold | number | 0.70 | Minimum match confidence 0.0–1.0 |
options.matchTimeout | number | — | Maximum 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.randomizeClickRadius | number | — | Overrides global click randomization settings with a specific radius. |
options.randomizeDelay | [number, number] | — | Randomized delay before tap (e.g. [50, 150]) |
Returns boolean — true 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
objectName | string | — | Name of the UI object defined in the visual editor |
options.duration | number | 500 | Hold duration in milliseconds |
options.threshold | number | 0.70 | Minimum match confidence 0.0–1.0 |
options.matchTimeout | number | — | Maximum 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.randomizeClickRadius | number | — | Overrides global click randomization settings with a specific radius. |
options.randomizeDelay | [number, number] | — | Randomized delay before long press (e.g. [50, 150]) |
Returns boolean — true 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.
| Parameter | Type | Description |
|---|---|---|
objectName | string | Name of the UI object; taps its fixed bounding-box center |
x, y | number | Screen coordinates in current device pixels |
options.randomizeClickRadius | number | Jitter 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 boolean — true 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
x1, y1 | number | — | Start coordinates in current device pixels |
x2, y2 | number | — | End coordinates in current device pixels |
options.duration | number | 300 | Swipe duration in milliseconds |
options.randomizeClickRadius | number | — | Overrides global click randomization settings with a specific radius. |
options.randomizeDelay | [number, number] | — | Randomized delay before swipe (e.g. [50, 150]) |
Returns boolean — true 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
objectName | string | — | Name of the UI object; presses its fixed bounding-box center |
x, y | number | — | Coordinates to press in current device pixels |
options.duration | number | 500 | Hold duration in milliseconds |
options.randomizeClickRadius | number | — | Overrides global click randomization settings with a specific radius. |
options.randomizeDelay | [number, number] | — | Randomized delay before long press (e.g. [50, 150]) |
Returns boolean — true 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
positions | Array<[x, y, duration?]> | — | Array of [x, y] or [x, y, duration] tuples |
options.duration | number | 500 | Fallback hold duration in ms for fingers that do not specify their own |
options.randomizeClickRadius | number | — | Jitter 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 boolean — true 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 separatespawnThread+longPresscalls? Android's AccessibilityService only allows one active gesture at a time. Dispatching a second gesture cancels the first, so three concurrentlongPresscalls will cancel each other in a rapid loop, causing visible flickering.multiLongPresspacks 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
fingers | Array<[x1, y1, x2, y2]> | — | Array of swipe coordinate tuples |
options.duration | number | 300 | Duration of the entire multi-swipe gesture in ms |
options.randomizeClickRadius | number | — | Radius (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 boolean — true 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.
| Parameter | Type | Description |
|---|---|---|
gestureName | string | Name of the recorded gesture |
Returns boolean — true 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
cx, cy | number | — | Center of the gesture in current device pixels |
amount | number | — | Positive = zoom in, negative = zoom out (pixel span delta) |
options.duration | number | 300 | Gesture duration in milliseconds |
options.randomizeClickRadius | number | — | Jitter 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 boolean — true 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 (userandomizeClickRadiusto 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 exactcx, cywith the exactdurationyou pass.
keyEvent(keyCode)
Sends an Android key event. Use the built-in KeyCode object for readable named constants instead of raw numbers.
| Parameter | Type | Description |
|---|---|---|
keyCode | number | Android KeyEvent constant. See the KeyCode reference below. |
Returns boolean — true 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.
| Constant | Value | Description |
|---|---|---|
KeyCode.HOME | 3 | Home button |
KeyCode.BACK | 4 | Back button |
KeyCode.DPAD_UP | 19 | D-pad up |
KeyCode.DPAD_DOWN | 20 | D-pad down |
KeyCode.DPAD_LEFT | 21 | D-pad left |
KeyCode.DPAD_RIGHT | 22 | D-pad right |
KeyCode.DPAD_CENTER | 23 | D-pad center / confirm |
KeyCode.VOLUME_UP | 24 | Volume up |
KeyCode.VOLUME_DOWN | 25 | Volume down |
KeyCode.POWER | 26 | Power button |
KeyCode.TAB | 61 | Tab key |
KeyCode.SPACE | 62 | Space key |
KeyCode.ENTER | 66 | Enter / confirm |
KeyCode.DEL | 67 | Backspace |
KeyCode.ESCAPE | 111 | Escape key |
KeyCode.FORWARD_DEL | 112 | Delete (forward) |
KeyCode.APP_SWITCH | 187 | Recents / app switcher |
inputText(text)
Types text into the currently focused field.
| Parameter | Type | Description |
|---|---|---|
text | string | Text to type |
Returns boolean — true if the text was dispatched; false if no input field is focused
inputText("Hello world");