karagoz long-press
Presses a point and holds it, or finds one node in the tree and holds its center.
Runs on
- Android emulator
- Android device
- iOS simulator
- iOS device
karagoz long-press <x> <y> [--duration <ms>] [--tree] [--device <id>]karagoz long-press --text <label> [--timeout <ms>] [--duration <ms>] [--tree] [--device <id>]karagoz long-press --id <resource-id> [--timeout <ms>] [--duration <ms>] [--tree] [--device <id>]Give exactly one of <x> <y>, --text or --id. long-press finds a node as tap does.
Before you start
Section titled “Before you start”- On Android: the screen on and unlocked, so the press reaches the app. With the screen off, or on the always-on display or a screensaver, nothing is sent and the command fails with
DEVICE_NOT_READY. - On Android, for
--textand--id: no other UiAutomation client connected (Appium, Maestro,uiautomator events). - On an iOS simulator: Xcode 27 or newer, opened once, or a Mac that never had Xcode 27, where the press goes through Karagöz’s runner.
- On an iPhone: paired with the Mac, Developer Mode on, connected by USB cable, Settings > Developer > Enable UI Automation on, and Karagöz’s runner installed with
install-runner.
Options
Section titled “Options”| Option | Default | Meaning |
|---|---|---|
<x> <y> |
A point in screen pixels. Non-negative, decimals allowed (12, 12.5). |
|
--text <label> |
A node whose text or contentDesc equals the label, as in tap. |
|
--id <resource-id> |
A node whose resourceId equals the value, or ends with :id/<value>, as in tap. |
|
--duration <ms> |
1000 |
How long to hold. Whole milliseconds, 0 to 999999999. |
--timeout <ms> |
0 |
Keep reading the tree until a node matches or this much time has passed. Only with --text or --id. |
--tree |
off | Also return the screen after the action under tree. |
--device <id> |
see Device selection |
Examples
Section titled “Examples”karagoz long-press 540 1100{"device":"emulator-5554","x":540,"y":1100,"duration":1000}exit 0Output
Section titled “Output”{ "device": "emulator-5554", "x": 540, "y": 1100, "duration": 1000}devicestring- The adb serial, or the simulator's or iPhone's UDID.
xnumber- Where the press went, in screen pixels: the point given, or the matched node's center.
ynumber- Where the press went, in screen pixels: the point given, or the matched node's center.
durationnumber- How long the touch was held, in milliseconds.
elementobject- Only with
--textor--id, afterduration: the matched node, with the fieldstaplists. treeobject- Only with
--tree, last: the compact tree after the action,rotationandrootasui-treereturns them. treeErrorobject- Only with
--tree, when that read failed:codeandmessage. The action still ran.
Errors
Section titled “Errors”| Code | When |
|---|---|
INVALID_ARGS | No target or more than one ('long-press' takes <x> <y>, --text or --id), a single coordinate ('long-press' needs <x> <y>), --timeout with a point, or a malformed number. |
ELEMENT_NOT_FOUND | No node matches. |
ELEMENT_AMBIGUOUS | More than one node matches. |
ELEMENT_COVERED | The node's center is under the on-screen keyboard. |
DEVICE_NOT_READY | The device is offline, unauthorized or similar, or the simulator is Booting or Shutting Down. For tap, long-press, double-tap, swipe, text, and key except WAKEUP, SLEEP and POWER: an Android screen that is off, on the always-on display or on a screensaver. For tap, long-press, double-tap, swipe and key right after a boot: the simulator's input service did not answer within 4 s. For screenshot: an iPhone that is not paired yet, has Developer Mode off, is no longer paired with this Mac, or is locked since it restarted. For launch and open-url: a locked iPhone. For ui-tree, tap, long-press, double-tap, swipe, text and key, also an iPhone not connected by USB cable, locked, or with a developer it does not trust yet. For those seven, also a runner that did not start within 60 s (look at the phone: the passcode sheet for UI automation, or Enable UI Automation off). Or something else answering on the runner's port without this Mac's key, or another app holding that port. On a simulator of a Mac that never had Xcode 27: a runner that did not start within 60 s, or a port another process took. For logs: an iPhone not connected by USB cable, one this Mac holds no pairing record for, or one that refuses this Mac's session. The message says what to do. |
Node presses also get every ui-tree error. Every press can also get the errors of its target, as for tap.
- Karagöz sends the press as a swipe that does not move.
- View and Compose use the device’s long-press setting (
settings get secure long_press_timeout): 400 ms on stock Android, while Samsung offers 300 to 1500 ms. Flutter uses 500 ms. The 1000 ms default covers all of them but Samsung’s 1500 ms setting, which needs--duration. - Exit
0means Android accepted the event, not that the app reacted to it. Read the tree again to check.
On an iOS simulator
Section titled “On an iOS simulator”Same arguments and output. The touch goes to the simulator’s own input service and is held there, as for tap. On a Mac that never had Xcode 27 it goes through Karagöz’s runner.
- The first of
ui-tree,tap,long-press,double-tap,swipe,textorkeyon a simulator compiles a small helper, which takes a few seconds. NOT_SUPPORTEDwith Xcode 26 or older on a Mac that once had Xcode 27.
On an iPhone
Section titled “On an iPhone”Same arguments and output. Karagöz’s runner holds the touch, as for tap.
For a shorter --duration, pass more than the app’s press time. With a 0.5 s long press, 500 ms did not trigger it and 550 ms did.
MCP equivalent
Section titled “MCP equivalent”Arguments: x, y, text, id, duration, timeout, device. The names are the CLI's option and positional names.
Related commands
Section titled “Related commands”- karagoz ui-tree
- Find the node to press, and read the screen again after the press.
- karagoz tap
- Finds nodes the same way, and lists the fields of
elementand the errors both share.