Menu

Letting an AI agent tap an Android phone with real touch events instead of guessing from screenshots
📰

Letting an AI agent tap an Android phone with real touch events instead of guessing from screenshots

DEV Community: opensource·Tommy Shelby·18 days ago
#mQDazTiB
#devtoopensource#devto#dev#input#scrcpy
Long article (763 words) — no AI summary yet.
Reading 0:00
15s threshold

I've been wiring AI agents up to real Android phones. Two things kept going wrong. The agent misclicked, and some apps ignored the taps entirely. Here is what I found and what I ended up building.

Problem 1: guessing coordinates from screenshots

The usual loop is simple. Take a screenshot, show it to a model, ask where to tap, send adb shell input tap x y .

It works until it doesn't. The screenshot you send is often scaled down from the real framebuffer. The model's coordinates are then off by some factor, and the tap lands next to the button. Animations and overlays make it worse. A floating tool or a caption bubble can sit right on top of your target.

The fix is to stop guessing. Android already knows where every button is. UIAutomator can dump the view hierarchy as XML, with text, descriptions, IDs and bounds. Find the node, take the center of its bounds, tap there.

Problem 2: synthetic input gets rejected

adb shell input is handy. But it injects a synthesized event from a shell.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.