1.获取点击坐标
- 进入shell模式
adb shell
- 进入手机监听事件
getevent
3. 获取坐标
在需要获取的坐标位置,单击。
出现上图,即为获取成功。Ctrl+C停止。
003 0035 X坐标: 0000009a
003 0036 Y坐标: 000004a1
4. 坐标16进制转10进制
打开win自带的计算器,选择程序员模式。
BIN:二进制(1111)
OCT:八进制(17)
DEC:十进制(15)
HEX:十六进制(F)
分别输入十六进制的坐标:
0000009a
000004a1
分别得到
154
1185
即为点击X,Y坐标。
注:请检查是否开启“开发者模式”以及root,在“开发者选项”中,找到“点按操作反馈”和“指针位置”并勾选上。
2.根据坐标点击
#adb shell input tap x y
adb shell input tap 154 1185
3.在控件中输入信息
#adb shell input text 内容
adb shell input 123456
4.模拟手机按键
#adb shell input keyevent 编号
#详尽编号 需要自行查询 Android KeyCode 列表
adb shell input keyevent 3 // Home
adb shell input keyevent 4 // Back
adb shell input keyevent 19 //Up
adb shell input keyevent 20 //Down
adb shell input keyevent 21 //Left
adb shell input keyevent 22 //Right
adb shell input keyevent 23 //Select/Ok
adb shell input keyevent 24 //Volume+
adb shell input keyevent 25 // Volume-
adb shell input keyevent 82 // Menu 菜单
adb shell input keyevent --longpress 3 //长按 home键
5.滑动屏幕
adb shell input swipe x1 y1 x2 y2 // 手机滑动屏幕
x1 y1 开始坐标
x2 y2 结束坐标
adb shell input touchscreen swipe x1 y1 x2 y2 //上下滑动
adb shell input touchscreen swipe x1 y1 x2 y2 //左右滑动
6.拨打电话,发送短信
#拨打电话,模拟器不支持
adb shell am start -a android.intent.action.CALL tel:电话号码
#发送短信,模拟器不支持
adb shell am start -a android.intent.action.SENDTO -d sms:10086(发送目的号码) --es sms_body "hello"(短信内容) --ez exit_on_sent true
7.打开网页
adb shell am start -a android.intent.action.VIEW -d http://www.baidu.com
8.调试模式
# 获取调试模式
shell settings get global adb_enabled
# 取消调试模式
adb shell settings put global adb_enabled 0