Getevent & sendevent is a tool in the Android system. It can simulate multiple buttons and touch-screen operations to generate raw events. Raw events are processed by event hub to generate the final gesture events.
=== Getevent ===
Getevent monitors current events, mouse events, button events, drag and slide events, etc.
Dd device 1:/dev/input/event0
Name: "qwerty2"
/Dev/input/event0: 0001 001e 00000001
/Dev/input/event0: 0001 001e 00000000
Where/dev/input/event0 is the device name 0001 is type, 001e is the key code, and the last one varies according to the type
For example, the last one is to press the keydown of key A, and the last one is to press the keyup of key.
The specific definitions of type, code, and value can be found in the source code/frameworks/base/CORE/Java/Android/View/keyevent. java.
=== Sendevent ===
Command Format 2: ADB shell sendevent [device] [type] [Code] [value]
The sending time, in the same format as above. Note that in get, the code is displayed in hexadecimal notation, while in send, the Code must be in decimal notation. For example:
# Sendevent/dev/input/event0 1 5 1
This command is used to send the keydown message of number 4, so many 4 messages are printed on the screen (because keyup is not sent)
For example, ADB shell sendevent/dev/input/event0 1 229 1 means to press the menu key
ADB shell sendevent/dev/input/event0 1 229 0 means to press and release the menu key
Note: The preceding commands must be used in combination.
The command is as follows:
Key name Code
Menu 229
Back home 102
Back (back button) 158
Calls (call button) 231
End (End call button) 107
2. Send a mouse event (touch ):
Command Format: ADB shell sendevent [device] [type] [Code] [value]
Case 1: touch on a coordinate point
For example, if the X coordinate of the screen is 40 and the Y coordinate is 210, run the following command:
ADB shell sendevent/dev/input/event0 3 0 40
ADB shell sendevent/dev/input/event0 3 1 210
ADB shell sendevent/dev/input/event0 1 1 330 1 // touch
ADB shell sendevent/dev/input/event0 0 0 0 // It must have
ADB shell sendevent/dev/input/event0 1 330 0 // untouch
ADB shell sendevent/dev/input/event0 0 0 0 // It must have
Note: The above six groups of commands must be used together.
Scenario 2: simulate a sliding track (download and test with apaint software)
The following example shows a horizontal line starting with (100,200) and ending with (108,200) on apaint.
ADB shell sendevent/dev/input/event0 3 0 100 // start from point (100,200)
ADB shell sendevent/dev/input/event0 3 1 200
ADB shell sendevent/dev/input/event0 1 1 330 1 // touch
ADB shell sendevent/dev/input/event0 0 0 0
ADB shell sendevent/dev/input/event0 3 0 0 101 // step to point (101,200)
ADB shell sendevent/dev/input/event0 0 0 0
........................ // Must list each step, here just skip
ADB shell sendevent/dev/input/event0 3 0 0 108 // end point (108,200)
ADB shell sendevent/dev/input/event0 0 0 0
ADB shell sendevent/dev/input/event0 1 330 0 // untouch
ADB shell sendevent/dev/input/event0 0 0 0
Refer:
Http://topic.csdn.net/u/20100326/17/1f0fc5a1-3bd2-4294-aa35-1bcb73357aa3.html
Http://www.51testing.com/html/65/n-215865-2.html