python adb
import os import sys from PIL import Image from PIL import ImageDraw import keyboard import pyautogui import time import math import pyautogui as pag from math import cos, sin, pi isdebug = 0 # 坐标渲染到截图片上 只是为了调试 上线可以截图生成图片调试注释掉 def shejijiancefn(): gongji = [30, 30] pianyi = 20 jineng1 = [130, 130] jineng2 = [230, 230] jineng3 = [330, 330] if isdebug == 1: screenShell = "adb shell /system/bin/screencap -p /sdcard/screenshot.jpg&adb pull /sdcard/screenshot.jpg i:/adb/screenshot.jpg" os.system(screenShell) img_src = Image.open('i:/adb/screenshot.jpg') img_src = img_src.convert("RGB") a = ImageDraw.ImageDraw(img_src) a.rectangle((gongji[0]-pianyi, gongji[1]-pianyi, gongji[0]+pianyi, gongji[0]+pianyi), fill='black', outline='black', width=0) a.rectangle((jineng1[0]-pianyi, jineng1[1]-pianyi, jineng1[0] + pianyi, jineng1[0]+pianyi), fill='red', outline='red', width=0) a.rectangle((jineng2[0]-pianyi, jineng2[1]-pianyi, jineng2[0] + pianyi, jineng2[0]+pianyi), fill='blue', outline='blue', width=0) a.rectangle((jineng3[0]-pianyi, jineng3[1]-pianyi, jineng3[0]+pianyi, jineng3[0]+pianyi), fill='green', outline='green', width=0) time_stamp = time.time() img_src.save("i:/adb/debug/catnew" + str(round(time_stamp * 1000))+".jpg") tabshell = "adb shell input tap "+str(jineng2[0])+" "+str(jineng2[1]) print(tabshell) os.system(tabshell) def jiancepengzhuang(): shejijiancefn() keyboard.add_hotkey('x', jiancepengzhuang) keyboard.wait()
如果遇到什么不懂的地方直接关注公众号留言(本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。)
作者:newmiracle
出处:https://www.cnblogs.com/newmiracle/