欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

adb 控制手机动作

程序员文章站 2022-04-15 15:44:04
下载adb​​工具包,解压即可 https://download.csdn.net/download/kai402458953/10784310各种事件说明:https://blog.csdn.net/jlminghui/article/details/39268419连接USB,设置手机开发者选项 ......

下载adb​​工具包,解压即可  https://download.csdn.net/download/kai402458953/10784310

各种事件说明:https://blog.csdn.net/jlminghui/article/details/39268419

连接usb,设置手机开发者选项,安装手机助手

cmd进入adb.exe的安装目录,执行以下命令

    adb kill-server  关闭adb服务

    adb start-server 开启adb服务

    adb devices  查看连接的设备

滑动

1.命令:adb input swipe 600 800 300 800(向右滑动)

2.命令:adb input swipe 300 800 600 800(向左滑动)

3.命令:adb input swipe 300 80 300 800(向下滑动)

4.命令:adb input swipe 300 800 300 80(向上滑动)

5.命令:adb input swipe 300 800 300 80 1000(向上滑动1000)

点击

此x、y坐标对应的是真实的屏幕分辨率,所以要根据具体手机具体看,比如你想点击屏幕(x, y) = (250, 250)位置:

adb shell input tap 250 250

adb shell input tap 600 600  点击位置(mt)

adb shell input keyevent 4    返回键

最后一个是事件参数,以下是对照表:

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"

cmd /c  f:\\adb\\adb.exe shell input tap 500 500  运行cmd 执行指定文件夹下的命令
---------------------