时间:2022-11-24 09:11:14 | 栏目:Python代码 | 点击:次
下载地址一:https://developer.android.google.cn/studio/releases/platform-tools
下载地址二:https://www.androiddevtools.cn

将adb命令添加到环境变量
将解压后的目录,有adb.exe的目录路径添加到系统环境变量中

使用 adb version 命令查看是否安装成功

想要操作手机app,需要使用adb的各种命令
全网最全adb命令,请参考:https://www.jb51.net/article/218163.htm
import os, time
def execute(cmd):
command = "adb shell {}".format(cmd)
print(command)
os.system(command)
if __name__ == '__main__':
# 启动王者荣耀app
execute('am start -n com.tencent.wangzherongyao')
time.sleep(1)
# 点击app中的某个位置
execute('input tap 33 4545')
time.sleep(0.5)
# 输入文字
execute('input text wangzherongyao')
time.sleep(0.5)
# 点击发送
execute('input tap 600 500')
//也设置shell=True,就不会弹出cmd框
process = subprocess.Popen('adb shell input tap 14 1402',shell=True)