网友回复
andriod平台下开启开发者模式后,电脑端通过adb shell来控制手机点击触屏、滑动等操作。
adb下载地址:
Windows版本:https://dl.google.com/android/repository/platform-tools-latest-windows.zip
Mac版本:https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
Linux版本:https://dl.google.com/android/repository/platform-tools-latest-linux.zip
配置环境变量
按键windows+r打开运行,输入sysdm.cpl,回车。
高级》环境变量》系统变量》path
将adb的存放路径添加进path中
两次确定之后在重新打开命令行进行校验是否安装成功
手机连接电脑USB后执行adb devices 查看手机连接状态(手机端要开启开发者模式) 查询已连接设备/模拟器:adb devices 此处连接手机,需要手机在开发者模式开启USB调试功能。顺便也开启模拟按键功能,后面会用到。 该命令经常出现以下问题: offline —— 表示设备未连接成功或无响应; device —— 设备已连接; no device —— 没有设备/模拟器连接; List of devices attached 设备/模拟器未连接到 adb 或无响应 adb模拟按键操作
1.模拟文本输入操作 ## 模拟输入abc adb shell input text abc 2.通过键值模拟按键操作 ## 模拟按back键 adb shell input keyevent 4 ## 或者 adb shell input keyevent KEYCODE_BACK 3.通过坐标模拟点击操作 ## 点击横坐标300,纵坐标500的点 adb shell input tap 300 500 4.通过坐标模拟滑动操作 ## 从(200,300)的点划到(500,300)的点,滑动时间100ms adb shell input swipe 200 300 500 300 100 5.通过坐标模拟拖动操作 ## 从(100,1220)的点拖动到(500,620)的点,滑动时间2000ms adb shell input draganddrop 100 1220 500 620 2000 6.通过坐标模拟长按滑动操作(注意与滑动操作的区别) 按住不放,从(200,300)的点划到(201,301)的点,滑动时间2000ms,由于划动距离短,时间长,在一个图标之内则主观显示为长按操作 可以将游戏背包的物品拖动,扔到仓库。 adb shell input swipe 200 300 201 301 2000 7.模拟实体键长按操作 通过 getevent & 获取实体键键值 /dev/input/event4: 0001 0074 00000001 /dev/input/event4: 0000 0000 00000000 /dev/input/event4: 0001 0074 00000000 /dev/input/event4: 0000 0000 00000000 0074为电源键键值,转换为十进制为116,编写如下脚本 sendevent /dev/input/event4 1 116 1 sendevent /dev/input/event4 0 0 0 sleep 4 sendevent /dev/input/event4 1 116 0 sendevent /dev/input/event4 0 0 0 8.通过坐标/键值模拟同时按下两个键,用and连接 ## 电源键亮屏并滑动解锁 adb...
点击查看剩余70%