|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
电脑如何和手机连接,已安装ADB驱动,手机开发者模式已打开,USB调试已打开,但就是运行代码不能成功,无法运行代码截屏,哪位大神可以用图片加文字指导一下
代码如下
- import os
- from PIL import Image
- import time
- #获取图片
- def screen():
- #将手机截屏图片并保存在手机上
- os.system("adb shell screencap -p/sdcard/screen.png")
- #将保存图片上传到电脑上
- os.system("adb pull /sdcard/screen.png")
- screen()
- #处理图片
- def getDistance():
- #读取图片
- image = Image.open("screen.png")
- #读取图片宽度,高度(1080,1920)
- width = image.size[0]
- weight = image.size[1]
- print(width,weight)
- for i in range(915,916):
- for j in range(0,weight):
- if image.getpixel((i,j))[:3] == (254,119,146):
- print(j)
- yield j #返回值(生成器)
- getDistance()
- if __name__ == "__main__":
- for _ in range(10):
- screen()
- yposition = getDistance()
- for y in yposition:
- print(y)
- #点击手机屏幕
- os.system("adb shell input tap 915 {}".format(y))
- print("正在关注........")
- #翻页(1080,1920)间隔500毫秒
- os.system("adb shell input swipe 540 1500 540 225 500")
- #停顿0.5S
- time.sleep(0.5)
- print("正在翻页........")
复制代码
|
|