ADB analog keys and inputs

Source: Internet
Author: User

There is a adb shell very practical command called input , through which you can do some interesting things.

inputThe complete help information for the command is as follows:

Usage:input [<source;]<command> [<arg...] The Sources Are:mouse keyboard joystick touchnavigation Touchpad Trackball Stylus dpad gesture touchscreen gamepadthe com Mands and default sources Are:text<string> (default:touchscreen) keyevent [--longpress] <key code number or Name> ... (Default:keyboard) Tap <x> <y > (default:touchscreen) swipe <x1> <y1> <x2> <y2> [Duration (ms)] (Default:touchscreen) Press (Default:trackball) Roll <dx> <dy> (Default: trackball)                

For example, the use of adb shell input keyevent <keycode> commands, different keycode can achieve different functions, a complete list of keycode see KeyEvent, quote Part I think the following is interesting:

KeyCode meaning
3 HOME Key
4 Return key
5 Open the dial-up app
6 Hang up the phone
24 Increase volume
25 Lower Volume
26 Power key
27 Photo (required in camera application)
64 Open your browser
82 Menu key
85 Play/Pause
86 Stop playing
87 Play the next song
88 Play the previous song
122 Move the cursor to the beginning or top of the list
123 Move cursor to end of line or bottom of list
126 Resume Playback
127 Pause Playback
164 Mute
176 Open System settings
187 Switch Apps
207 Open a contact
208 Open calendar
209 Open music
210 Open Calculator
220 Reduce screen brightness
221 Improve screen brightness
223 System hibernation
224 Light the screen.
231 Turn on The voice assistant
276 Let the system hibernate if there is no wakelock

Here are input Some examples of the use of commands.

Power key

Command:

ADB shell Input KeyEvent 26

The execution effect is equivalent to pressing the power key.

Menu key

Command:

ADB shell Input KeyEvent 82
HOME Key

Command:

ADB shell Input KeyEvent 3
Return key

Command:

ADB shell Input KeyEvent 4
Volume control

To increase the volume:

ADB shell Input KeyEvent 24

To lower the volume:

ADB shell input KeyEvent 25

Mute:

ADB shell input KeyEvent 164
Media Control

Play/pause:

ADB shell Input KeyEvent 85

Stop playback:

ADB shell Input KeyEvent 86

Play the next song:

ADB shell Input KeyEvent 87

Play the previous song:

ADB shell input KeyEvent 88

Resume Playback:

ADB shell input KeyEvent 126

Pause Playback:

ADB shell Input KeyEvent 127
Lit/off Screen

You can toggle the on and off screens by using the analog power keys described above, but if you explicitly want to light or turn off the screen, you can use the following method.

To light the screen:

ADB shell Input KeyEvent 224

Off Screen:

ADB shell Input KeyEvent 223
Sliding unlock

If the lock screen does not have a password, it is unlocked by swiping gestures, which can then be unlocked input swipe .

Command (Parameters in Model Nexus 5, swipe up gesture to unlock an example):

ADB shell input swipe 300 1000 300 500

Parameters are 300 1000 300 500 indicated separately 起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐标 .

Enter text

When the focus is in a text box, you can enter text by using a input command.

Command:

adb shell input Text Hello

It now hello appears in the text box.

ADB analog keys and inputs

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.