Can someone explain this command completely adb shell sendevent [device] [type] [code] [value]?

Can anyone fully explain the following command:

adb shell sendevent [device] [type] [code] [value] 

I am trying to write a script for touch events using the send event command.

+7
source share
2 answers

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 .

+8
source

Im using ZTE blade (1.gen) CyanagenMod 7. The screen resolution is 480x800. After some trial and error, I realized that in order to click the coordinates of 240x725y, I really had to implement the script as follows: 988 = 240x, 2768 = 725y

 sendevent /dev/input/event0 3 53 988 sendevent /dev/input/event0 3 54 2768 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 

I previously recorded events with the get event and the values ​​it gave were correct, I just did not know how to interpret them =).

0
source

All Articles