ADB基本操作及实现游戏自动对战
基础知识
首先需要在电脑上装ADB,数据线连接手机,并调成USB调试模式
,在命令行可以测试以下命令:
// 查看已连接的设备
adb devices
// 连接
adb connect 192.168.31.198:5555
// 点击
adb shell input tap [位置]
// 滑动
adb shell input swipe [位置] [位置] [时间]
[屏幕上的位置坐标]
[时间 单位为ms]
实现游戏自动对战
查看设备是否连上:
C:\Users\Administrator>adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
a8278daa device
使用Jupyter Notebook运行程序
C:\Users\Administrator>jupyter notebook
打开并运行Demo
该程序是事先写好的,实现了在“野蛮人大作战”游戏中实现对战N次,在游戏中会四处乱走乱打,游戏结束自动开启下一局,可用来刷游戏次数。
#野蛮人大作战-自动对战n次的完整代码
import os
import random
import time
btn_yule="1750 800"
btn_duiz="1870 970"
btn_end="1988 1010"
btn_next="2010 1000"