Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用指南 #5

Closed
cndaqiang opened this issue Jan 14, 2024 · 19 comments
Closed

使用指南 #5

cndaqiang opened this issue Jan 14, 2024 · 19 comments

Comments

@cndaqiang
Copy link
Owner

cndaqiang commented Jan 14, 2024

不要直接点击object.py运行

  • 要么在cmd/powershell/terminal中运行
  • 要么使用airTestIDE运行

简易版

备注

  • 脚本是在分辨率960*540的模拟器下采样的图片, 2k屏的手机大部分功能可以使用,存在极个别图片无法识别的可能行, 若有问题,用AirTest IDE中的touch功能重新采样即可

虚拟机推荐

  • windows虚拟机推荐bluestack,可以开启低性能模式,5帧低画质,5年前的笔记本也能轻松多开2个账户以上
  • windows 雷电虚拟机也可以,但是设置最低是60帧,太浪费电脑的性能了。电脑如果带不动60帧,还容易卡

下面是不同的案例

@cndaqiang
Copy link
Owner Author

cndaqiang commented Jan 14, 2024

全终端控制单台小米手机示例

电脑配置

手机打开ADB无线配对,电脑adb连接

image

(base) cndaqiang@macmini ~$ adb pair 192.168.12.109:39833
Enter pairing code: 527695
Successfully paired to 192.168.12.109:39833 [guid=adb-4e86ac13-GhtB4l]
#注意配对端口和连接端口不一样
(base) cndaqiang@macmini ~$ adb connect 192.168.12.109:41857
connected to 192.168.12.109:41857

修改本仓库代码

(base) cndaqiang@macmini tmp$ wget https://github.com/cndaqiang/AirTest_MobileAuto_WZRY/archive/refs/tags/1.0.3.zip
--2024-01-14 22:21:10--  https://github.com/cndaqiang/AirTest_MobileAuto_WZRY/archive/refs/tags/1.0.3.zip
正在解析主机 github.com (github.com)... 20.205.243.166
正在连接 github.com (github.com)|20.205.243.166|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://codeload.github.com/cndaqiang/AirTest_MobileAuto_WZRY/zip/refs/tags/1.0.3 [跟随至新的 URL]
--2024-01-14 22:21:10--  https://codeload.github.com/cndaqiang/AirTest_MobileAuto_WZRY/zip/refs/tags/1.0.3
正在解析主机 codeload.github.com (codeload.github.com)... 20.205.243.165
正在连接 codeload.github.com (codeload.github.com)|20.205.243.165|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:未指定 [application/zip]
正在保存至: “1.0.3.zip”

1.0.3.zip                             [    <=>                                                       ]   2.93M  4.60MB/s  用时 0.6s

2024-01-14 22:21:12 (4.60 MB/s) - “1.0.3.zip” 已保存 [3077386]

(base) cndaqiang@macmini tmp$ unzip 1.0.3.zip
(base) cndaqiang@macmini tmp$ cd  AirTest_MobileAuto_WZRY-1.0.3/

修改object.py这一行,填入刚才连接的端口和ip
image
启动(保持手机屏幕不锁定)

(base) cndaqiang@macmini AirTest_MobileAuto_WZRY-1.0.3$ ./object.py
[01-14 22:26:34](0/1)(0/1):LINK=Android:///192.168.12.109:41857
[01-14 22:26:34](0/1)(0/1):设备类型=android
[01-14 22:26:34](0/1)(0/1):mynode=0
[01-14 22:26:34](0/1)(0/1):totalnode=1
[01-14 22:26:34](0/1)(0/1):APPID=com.tencent.tmgp.sgame
[01-14 22:26:34](0)Android:///192.168.12.109:41857:开始第1/4次连接
[01-14 22:26:36](0)Android:///192.168.12.109:41857:链接成功
[01-14 22:26:36](0)对战模式:5v5匹配
[01-14 22:26:36](0)remove[(0)NeedRebarrier.txt]
[01-14 22:26:36](0)不存在[(0)NeedRebarrier.txt]

@cndaqiang
Copy link
Owner Author

cndaqiang commented Jan 14, 2024

图形化控制无线单台小米手机示例

电脑下载AieTest并安装打开

https://airtest.netease.com/

电脑无线连接手机的ADB(同上)

image

(base) cndaqiang@macmini ~$ adb pair 192.168.12.109:39833
Enter pairing code: 527695
Successfully paired to 192.168.12.109:39833 [guid=adb-4e86ac13-GhtB4l]
#注意配对端口和连接端口不一样
(base) cndaqiang@macmini ~$ adb connect 192.168.12.109:41857
connected to 192.168.12.109:41857

电脑AirTest打开下载的代码,把ip和端口调整为手机的ip和端口

image 保存后,点击运行 image 这里显示日志 image

图形化有线控制小米手机示例

image

@cndaqiang
Copy link
Owner Author

cndaqiang commented Jan 20, 2024

Windows全新安装python、依赖+雷电模拟器

Windows安装python

PowerShell执行python,会弹出窗口点击安装
image
安装完成后执行下面命令

python.exe -m pip install --upgrade pip
python -m pip  install -i https://pypi.tuna.tsinghua.edu.cn/simple  airtest
python -m pip  install -i https://pypi.tuna.tsinghua.edu.cn/simple pathos

image

雷电模拟器配置

我之前一直使用的是Bluestack适合多开,这次尝试下雷电,使用的版本雷电模拟器 9.0.65.0 去广告绿色版,设置如下
image
image

雷电模拟器自己安装WZRY,登录账户

初次使用,强烈建议WZRY的设置中采用低画质、低刷新率等, 最好自己点击一次5v5人机对战,因为在新设备上登录,对战过程会各种提示新赛季的新功能

下载代码执行

从这里下载zip后
image
解压,进入到解压目录,直接运行.
image
image

@Galaxyduan
Copy link

脚本运行闪退 无法加载啊

@cndaqiang
Copy link
Owner Author

脚本运行闪退 无法加载啊

提供完整的运行截图 @Galaxyduan

@Pain2021
Copy link

1707720128534这种怎么搞

@cndaqiang
Copy link
Owner Author

cndaqiang commented Feb 13, 2024

1707720128534这种怎么搞


首先建议把下面的函数

def connect_status(times=10):
    png = Template(r"tpl_target_pos.png", record_pos=(-0.28, 0.153), resolution=(960, 540))
    for i in np.arange(times):
        try:
            exists_o(png)
            return True
        except:
            print(f"cndaqiang: 无法连接设备,重试中{i}")
            sleep(1)
            continue
    print("cndaqiang: 设备失去联系")
    return False

改为

def connect_status(times=10):
    png = Template(r"tpl_target_pos.png", record_pos=(-0.28, 0.153), resolution=(960, 540))
    exists_o(png)
    return True

看报错信息是什么


连接失败后,程序会再次尝试连接,现在没有继续尝试连接的日志,不好判断是设备失联了,还是airtest配置失败


如果是连接失败:

在脚本刚运行时连接成功了,但脚本执行到了这里时,失去联系了
image

你的安卓设备是不是和你的电脑失去联系了(比如安卓虚拟机关机,阻止了ADB调试, 连接不稳定,虚拟机的adb端口不是5555?),或者没有允许ADB调试,ADB没有开启图像识别、模拟点击的权限


@Pain2021
Copy link

1707819764564
airtest远程连接端口是5555.

@cndaqiang
Copy link
Owner Author

cndaqiang commented Feb 13, 2024

1707819764564 airtest远程连接端口是5555.

嗯,连接地址应该是没有问题的,

我不清楚你运行object.py的终端是否和airtest客户端进行ADB显示画面时,两个ADB冲突了,

按照我上一个回复的做一下,现在日志不全,判断不出来

@cndaqiang
Copy link
Owner Author

cndaqiang commented Feb 13, 2024

1707819764564 airtest远程连接端口是5555.

我怀疑是airtest的IDE软件和你在cmd终端中执行object.py冲突了。
因为我刚才测试了,先用cmd终端执行object.py正常控制,这时候我再打开airtestIDE连接安卓模拟器,终端的ADB就会断开,无法进行控制,脚本提示连接失败。

这时及时关闭airTestIDE后,脚本会重新连接的
image


所以要么在airTestIDE软件中执行脚本,要么在终端中执行脚本,不要两个同时打开

@Pain2021
Copy link

Pain2021 commented Feb 14, 2024

未运行airtest。修改为以下代码,点击object.py运行,cmd直接迅速闪退

def connect_status(times=10):
    png = Template(r"tpl_target_pos.png", record_pos=(-0.28, 0.153), resolution=(960, 540))
    exists_o(png)
    return True

@cndaqiang
Copy link
Owner Author

未运行airtest。修改为以下代码,点击object.py运行,cmd直接迅速闪退

def connect_status(times=10):
    png = Template(r"tpl_target_pos.png", record_pos=(-0.28, 0.153), resolution=(960, 540))
    exists_o(png)
    return True

要么用airtestIDE运行,要么在终端里运行。
不要点击运行,这样你看不到报错信息。

请在cmd/powershell中运行,并提供完整的报错截图记录,
#5 (comment)

@Pain2021
Copy link

cmd里可以运行了。

@1181691792
Copy link

死活连接不上,出现一个架构不同兼容性的问题,psutil 模块尝试加载的库文件(_psutil_osx.abi3.so)是一个不兼容的架构(arm64,需要的是 x86_64),不知道是不是这个导致的连接失败

@1181691792
Copy link

出现

解决冲突后,就成功连接了

@alen157
Copy link

alen157 commented May 7, 2024

希望来个刷战令任务的

@alen157
Copy link

alen157 commented May 8, 2024

一直在这个页面寻找大半天都不带动的什么情况啊
Uploading mmexport1715151123486.png…

@cndaqiang
Copy link
Owner Author

刷一上午人机,一周的战令就完成了

希望来个刷战令任务的

@cndaqiang
Copy link
Owner Author

死活连接不上,出现一个架构不同兼容性的问题,psutil 模块尝试加载的库文件(_psutil_osx.abi3.so)是一个不兼容的架构(arm64,需要的是 x86_64),不知道是不是这个导致的连接失败

我的x86 intel (windows/MacOS) arm64(ubuntu)都可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants