Appium+python Automation 38-adb Shell key operation (input keyevent)

Source: Internet
Author: User
Tags appium

Objective

Then the previous article introduces the key operation KeyEvent event in input, and sends some key actions commonly used on the phone.

KeyEvent

1.keyevent event has a corresponding table, you can directly send the corresponding number, or the way string, the following two methods can implement the back key. Open cmd Input command

# 方法一:> adb shell input keyevent KEYCODE_BACK# 方法二:> adb shell input keyevent 4

2. Common KeyEvent Events

    • Unlock (keycode_notification): adb shell input KeyEvent 83

    • Up (keycode_dpad_up): adb shell input keyevent 19

    • Down (keycode_dpad_down): adb shell input keyevent 20

    • Left (keycode_dpad_left): adb shell input keyevent 21

    • Right (keycode_dpad_right): adb shell input keyevent 22

KeyEvent Event Correspondence Number

0–> "Keycode_unknown"
1–> "Keycode_menu"
2–> "Keycode_soft_right"
3–> "Keycode_home"
4–> "Keycode_back"
5–> "Keycode_call"
6–> "Keycode_endcall"
7–> "Keycode_0"
8–> "Keycode_1"
9–> "Keycode_2"
10–> "Keycode_3"
11–> "Keycode_4"
12–> "Keycode_5"
13–> "Keycode_6"
14–> "Keycode_7"
15–> "Keycode_8"
16–> "Keycode_9"
17–> "Keycode_star"
18–> "Keycode_pound"
19–> "Keycode_dpad_up"
20–> "Keycode_dpad_down"
21–> "Keycode_dpad_left"
22–> "Keycode_dpad_right"
23–> "Keycode_dpad_center"
24–> "Keycode_volume_up"
25–> "Keycode_volume_down"
26–> "Keycode_power"
27–> "Keycode_camera"
28–> "Keycode_clear"
29–> "Keycode_a"
30–> "Keycode_b"
31–> "Keycode_c"
32–> "Keycode_d"
33–> "Keycode_e"
34–> "Keycode_f"
35–> "Keycode_g"
36–> "Keycode_h"
37–> "Keycode_i"
38–> "Keycode_j"
39–> "Keycode_k"
40–> "Keycode_l"
41–> "Keycode_m"
42–> "Keycode_n"
43–> "Keycode_o"
44–> "Keycode_p"
45–> "Keycode_q"
46–> "Keycode_r"
47–> "keycode_s"
48–> "keycode_t"
49–> "Keycode_u"
50–> "Keycode_v"
51–> "Keycode_w"
52–> "Keycode_x"
53–> "Keycode_y"
54–> "Keycode_z"
55–> "Keycode_comma"
56–> "Keycode_period"
57–> "Keycode_alt_left"
58–> "Keycode_alt_right"
59–> "Keycode_shift_left"
60–> "Keycode_shift_right"
61–> "Keycode_tab"
62–> "Keycode_space"
63–> "Keycode_sym"
64–> "Keycode_explorer"
65–> "Keycode_envelope"
66–> "Keycode_enter"
67–> "Keycode_del"
68–> "Keycode_grave"
69–> "Keycode_minus"
70–> "Keycode_equals"
71–> "Keycode_left_bracket"
72–> "Keycode_right_bracket"
73–> "Keycode_backslash"
74–> "Keycode_semicolon"
75–> "Keycode_apostrophe"
76–> "Keycode_slash"
77–> "Keycode_at"
78–> "Keycode_num"
79–> "Keycode_headsethook"
80–> "Keycode_focus"
81–> "Keycode_plus"
82–> "Keycode_menu"
83–> "Keycode_notification"
84–> "Keycode_search"
85–> "Tag_last_keycode"

Encapsulating KeyEvent Events

Text input literal

1.ADB can also enter text

adb shell input Text Yoyoketang

Note: Chinese is not input, such as: Shanghai-leisurely

Appium+python Automation 38-adb Shell key operation (input keyevent)

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.