RootAutomator
RootAutomator
root_automator.RootAutomator
Inject touch, swipe, long-press, and raw sendEvent traffic through root or adb shell access. Unlike pure accessibility automation, you can drive multi-touch and arbitrary gesture paths, at the cost of device-specific quirks.
Warning
Since Pro 9.3, prefer RootAutomator2—it tracks the same APIs with better OEM compatibility.
Table of contents
Methods
Methods
sendEvent
▸ sendEvent(type, code, value): void
Enqueue a raw Linux input event (EV_KEY, EV_ABS, …).
Parameters
| Name | Type | Description |
|---|---|---|
type | number | Event type. |
code | number | Event code. |
value | number | Event value. |
Returns
void
syncReport
▸ syncReport(): void
Flush the outbound queue so every synthesized event reaches the kernel.
Returns
void
touch
▸ touch(x, y): void
Move the virtual contact to (x, y) without synthesizing a full down/up pair (low-level helper).
Parameters
| Name | Type | Description |
|---|---|---|
x | number | X in pixels. |
y | number | Y in pixels. |
Returns
void
touchX
▸ touchX(x): void
Update only the X coordinate of the active contact.
Parameters
| Name | Type | Description |
|---|---|---|
x | number | X in pixels. |
Returns
void
touchY
▸ touchY(y): void
Update only the Y coordinate of the active contact.
Parameters
| Name | Type | Description |
|---|---|---|
y | number | Y in pixels. |
Returns
void
sendSync
▸ sendSync(): void
Send a SYN_REPORT-style synchronization barrier (implementation detail for batching).
Returns
void
tap
▸ tap(x, y, id?): Promise<void>
Quick tap (~5 ms contact time) at (x, y) for pointer id.
Example
"nodejs";
const { createRootAutomator } = require("root_automator");
async function main() {
const ra = await createRootAutomator({ root: true });
await ra.tap(100, 100);
await ra.exit();
}
main();Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | number | undefined | X in pixels. |
y | number | undefined | Y in pixels. |
id | number | 0 | Pointer / finger slot. |
Returns
Promise<void>
Resolves when the tap sequence finishes.
swipe
▸ swipe(x1, y1, x2, y2, duration, id?, sampleMs?): Promise<void>
Drag from (x1, y1) to (x2, y2) over duration ms. Intermediate points are emitted every sampleMs (default 8).
Example
"nodejs";
const { createRootAutomator } = require("root_automator");
async function main() {
const ra = await createRootAutomator({ root: true });
await ra.swipe(100, 100, 200, 200, 300);
await ra.exit();
}
main();Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x1 | number | undefined | Start X. |
y1 | number | undefined | Start Y. |
x2 | number | undefined | End X. |
y2 | number | undefined | End Y. |
duration | number | undefined | Gesture duration (ms). |
id | number | 0 | Pointer slot. |
sampleMs | number | 8 | Sampling interval between points. |
Returns
Promise<void>
press
▸ press(x, y, duration, id?): Promise<void>
Hold (x, y) for duration ms, then release.
Example
"nodejs";
const { createRootAutomator } = require("root_automator");
async function main() {
const ra = await createRootAutomator({ root: true });
await ra.press(100, 100, 500);
await ra.exit();
}
main();Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | number | undefined | X in pixels. |
y | number | undefined | Y in pixels. |
duration | number | undefined | Hold time (ms). |
id | number | 0 | Pointer slot. |
Returns
Promise<void>
longPress
▸ longPress(x, y, id?): Promise<void>
System long-press duration: ViewConfiguration.getLongPressTimeout() + 100 ms.
Example
"nodejs";
const { createRootAutomator } = require("root_automator");
async function main() {
const ra = await createRootAutomator({ root: true });
await ra.longPress(100, 100);
await ra.exit();
}
main();Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | number | undefined | X in pixels. |
y | number | undefined | Y in pixels. |
id | number | 0 | Pointer slot. |
Returns
Promise<void>
touchDown
▸ touchDown(x, y, id?): void
Synthesize ACTION_DOWN at (x, y).
Example
"nodejs";
const { createRootAutomator } = require("root_automator");
async function main() {
const ra = await createRootAutomator({ root: true });
ra.touchDown(100, 100);
ra.touchMove(200, 200);
ra.touchUp();
await ra.exit();
}
main();Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | number | undefined | X in pixels. |
y | number | undefined | Y in pixels. |
id | number | 0 | Pointer slot. |
Returns
void
touchUp
▸ touchUp(id?): void
Synthesize ACTION_UP for pointer id.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | number | 0 | Pointer slot. |
Returns
void
touchMove
▸ touchMove(x, y, id?): void
Synthesize ACTION_MOVE to (x, y).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
x | number | undefined | X in pixels. |
y | number | undefined | Y in pixels. |
id | number | 0 | Pointer slot. |
Returns
void
exit
▸ exit(forced?): Promise<void>
Tear down the injector process.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
forced | boolean | false | true kills the worker immediately; false waits for the current gesture to finish. |
Returns
Promise<void>
Resolves after shutdown completes.
