转自http://www.softteco.com/blog/android-low-level-shell-click-on-screen/
Guys, nowdays, approach in this article is really senseless.
To send touch event you need to do:
1 Set coordinates:
adb shell sendevent /dev/input/event2 3 0 x adb shell sendevent /dev/input/event2 3 1 y
2 Send touch event (must have 0 0 0 pair):
adb shell sendevent /dev/input/event2 1 330 1 adb shell sendevent /dev/input/event2 0 0 0
3 Send release finger event (must have 0 0 0 pair):
adb shell sendevent /dev/input/event2 1 330 0 adb shell sendevent /dev/input/event2 0 0 0
Please note:
1 You can record events:
adb shell getevent
2 if you use getevent all event values are in hex.
CONFIRMED, THIS WAY IS NOT WORKING ANYMORE, at least for Android 2.2.
I have rechecked, Android low level events signature was changed starting from Android 2.2 Froyo.
I just dumped single click:
/dev/input/event2: 0003 0030 00000068
/dev/input/event2: 0003 0032 0000000a
/dev/input/event2: 0003 0035 0000022e
/dev/input/event2: 0003 0036 00000039
/dev/input/event2: 0000 0002 00000000
/dev/input/event2: 0003 0012 0000002f
/dev/input/event2: 0003 0014 00000001
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0003 0030 00000000
/dev/input/event2: 0003 0032 0000000a
/dev/input/event2: 0003 0035 0000022e
/dev/input/event2: 0003 0036 00000039
/dev/input/event2: 0000 0002 00000000
/dev/input/event2: 0003 0012 00000020
/dev/input/event2: 0003 0014 00000000
/dev/input/event2: 0000 0000 00000000
It has obviously another structure.. I’m investigating right now this situation,
solution will be here tomorrow
After a quick investigation I have reproduced the click for Froyo Android:
Perl script (click on screen at 558, 57 point):
system(“adb shell sendevent /dev/input/event2 0003 48 104“);
system(“adb shell sendevent /dev/input/event2 0003 50 10“);
system(“adb shell sendevent /dev/input/event2 0003 53 558“);
system(“adb shell sendevent /dev/input/event2 0003 54 57“);
system(“adb shell sendevent /dev/input/event2 0000 2 00000000“);
system(“adb shell sendevent /dev/input/event2 0003 18 47“);
system(“adb shell sendevent /dev/input/event2 0003 20 00000001“);
system(“adb shell sendevent /dev/input/event2 0000 0000 00000000“);
system(“adb shell sendevent /dev/input/event2 0003 48 00000000“);
system(“adb shell sendevent /dev/input/event2 0003 50 10“);
system(“adb shell sendevent /dev/input/event2 0003 53 558“);
system(“adb shell sendevent /dev/input/event2 0003 54 57“);
system(“adb shell sendevent /dev/input/event2 0000 0002 00000000“);
system(“adb shell sendevent /dev/input/event2 0003 18 32“);
system(“adb shell sendevent /dev/input/event2 0003 20 00000000“);
system(“adb shell sendevent /dev/input/event2 0000 0000 00000000“);
How I did it:
1. Start dump motion event you need to reproduce:
grep is very useful to filter output.
2. Do motion event you want to reproduce;
3. Than just convert all values from hex in dump to decimal values!
To find what eventX is working for you do following:
1. Start terminal and type
Please check my tutorial for low level interaction with device
Happy motion events reproducing! (:
Best regards,
Yahor