Can anyone explain the following command fully:
adb shell sendevent [device] [type] [code] [value]
I am trying to write a script for touch events using send event command.
First you need to find out the name of the touchscreen device on your phone or tablet. You can use this command in adb shell
session:
getevent -pl 2>&1 | sed -n '/^add/{h}/ABS_MT_TOUCH/{x;s/[^/]*//p}'
Let's say the input device name is /dev/input/event0
and you want to emulate a quick tap at 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
The long touch (let's say 1sec long) at the same coordinates would be:
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 the explanation what those commands mean and do exactly please read Emulating touchscreen interaction with sendevent in Android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With