First you need to find out the name of the touch device on your phone or tablet. You can use this command in an adb shell session:
getevent -pl 2>&1 | sed -n '/^add/{h}/ABS_MT_TOUCH/{x;s/[^/]*//p}'
Let's say the name of the input device is /dev/input/event0 , and you want to emulate a quick jump in the coordinates x = 300, y = 400:
sendevent /dev/input/event0 3 53 300 sendevent /dev/input/event0 3 54 400 sendevent /dev/input/event0 3 48 5 sendevent /dev/input/event0 3 58 50 sendevent /dev/input/event0 0 2 0 sendevent /dev/input/event0 0 0 0 sendevent /dev/input/event0 0 2 0 sendevent /dev/input/event0 0 0 0
Long touch (let them say 1sec long) in the same coordinates:
sendevent /dev/input/event0 3 53 300 sendevent /dev/input/event0 3 54 400 sendevent /dev/input/event0 3 48 5 sendevent /dev/input/event0 3 58 50 sendevent /dev/input/event0 0 2 0 sendevent /dev/input/event0 0 0 0 sleep 1 sendevent /dev/input/event0 0 2 0 sendevent /dev/input/event0 0 0 0
For an explanation of what these commands mean and how, read Emulation of touchscreen interaction with sendevent in Android .
Alex P.
source share