ADB (7)-Analog key/input

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 []  [...]The sources are:      mouse      keyboard      joystick      touchnavigation      touchpad      trackball      stylus      dpad      gesture      touchscreen      gamepadThe commands and default sources are:      text  (Default: touchscreen)      keyevent [--longpress]  ... (Default: keyboard)      tap   (Default: touchscreen)      swipe     [duration(ms)] (Default: touchscreen)      press (Default: trackball)      roll   (Default: trackball)

For example, the use of adb shell input keyevent  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 (7)-Analog key/input

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.