[Android] via adb shell input Escalation command simulates screen click event "Go"

Source: Internet
Author: User

This article was reproduced from: http://blog.csdn.net/yuanzihui/article/details/52871652

Common input escalation commands:
Input text 1234 actually injected 1234 text into the interface, there is an input box, can obviously see the effect
Input KeyEvent 4 Keyboard event, 4 for return
Input TAP 100 300 click on Touchscreen event, simulate click x=100 y = 300 position
Input swipe 100 300 500 300 touchscreen slide event, analog slide, from X =100
y = 300 slide to x=500 y=300 position
Input press simulates pressing the trackball
Input roll 100 300 analog trackball slide x direction y direction 300

Get Coordinate method:
First step: Calculate scale

ADB Shell Getevent-p | Grep-e "0035"-E "0036"
Get the Event System width (0035) and high (0036)

In the case of the phone I'm currently using, the command will output the following information:
0035:value 0, Min 0, max 1602, Fuzz 0, flat 0, resolution 0
0036:value 0, Min 0, max 2503, fuzz 0, flat 0, resolution 0

0035 (w) Max 1602
0036 (h) Max 2503

Calculate the scale (with a known screen resolution, such as 1080p: 1080 (W) * 1920 (h)):
Ratew = 1080 (width of the phone screen)/1602 (max in event 0035) = 0.674
Rateh = 1920 (high on the phone screen)/2503 (max in event 0036) = 0.767

Step Two: Click on the screen to calculate the coordinates of the click position
ADB Shell GetEvent | Grep-e "0035"-E "0036"
Click on the desired location on the screen and the following output will be available:
/dev/input/event0:0003 0035 00000341
/dev/input/event0:0003 0036 000008ec

Converts the position data from 16 to 10 in the back of 0035 and 0036
width = 0x341 = 3*16*16 + 4*16 + 1 = 833
Height = 0x8ec = 8*16*16 + 14*16 + 12 = 2284
This is the position in the event system and translates it into a screen position
Screenw = Width*ratew = 833*0.674 = 561
Screenh = Height*rateh = 2284*0.767 = 1751

Finally figured it out.
The screen position coordinates just clicked (561, 1751)

[Android] via adb shell input Escalation command simulates screen click event "Go"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.