1. 截图并保存至电脑 ---windows
adb shell screencap -p > D:login.png
windows下这种方法保存会报图片格式错误,使用python处理一下,即可打开。
原因: 重定向后,换行的格式为 ,需要转换成windows识别的
def convert_img(): with open("https://blog.csdn.net/chengxuyuan20100425/article/details/login.png", "rb") as f: bys = f.read() bys_ = bys.replace(b" ",b" ") # 二进制流中的" " 替换为" " with open("https://blog.csdn.net/chengxuyuan20100425/article/details/login.png", "wb") as f: f.write(bys_) f.close()
2. abd 通过无线方法连接手机
打开端口:adb tcpip 5555
建议连接:
adb connect 192.168.251.103(手机上的IP地址)
如果USB和无线同时连上,输入命令时,会报错,把USB拔掉即可:
断开无线连接:
adb disconnect 192.168.251.103