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,getPosition(...).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 | Overrides 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.
| 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 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
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 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.
| 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 |
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 (randomizeClickRadiusandrandomizeDelay) are not supported for this method.
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.
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 |
Returns void
pinch(540, 960, 200); // zoom in, default duration
pinch(540, 960, -200, { duration: 400 }); // zoom out, custom duration
Note: Randomization options (randomizeClickRadiusandrandomizeDelay) 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.
| Parameter | Type | Description |
|---|---|---|
keyCode | number | Android 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.
| 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 void
inputText("Hello world");