How to use ADB to send touch events to device using sendevent command?

Harkish picture Harkish · Aug 9, 2010 · Viewed 152.1k times · Source

I am trying to send touch events to a device using AndroidDebugBridge, so that I can do some basic automation for UI tests. I have followed the discussion in LINK. I am able to use sendevent to simulate touch on emulators, but unable to do the same on a device.

Like in above link the emulator seems to send out 6 events for each touch ( xcoord, ycoord, 2 for press,2 for release) and it was easy to use this information to sendevents, but a getevent for the touchscreen for a device seems to generate far too many events.

Has somebody managed to send touch from ADB to a device? Could you please share the solution.

Answer

user643154 picture user643154 · Mar 22, 2011

Android comes with an input command-line tool that can simulate miscellaneous input events. To simulate tapping, it's:

input tap x y

You can use the adb shell ( > 2.3.5) to run the command remotely:

adb shell input tap x y