给自己一个Note 为了玩自动化必须要学点OpenCV
import pyautogui as pg
from time import sleep
import cv2 as cv
sleep(3)
def findImg(tmpImg):
img = pg.screenshot()
img.save("./images/shot.png")
shot = cv.imread("./images/shot.png")
template = cv.imread(tmpImg)
result = cv.matchTemplate(shot,template,cv.TM_CCOEFF_NORMED) #标准匹配方式
pos_start = cv.minMaxLoc(result)[3]
x = int(pos_start[0]) + int(template.shape[1]/2)
y = int(pos_start[1]) + int(template.shape[0]/2)
pg.moveTo(x,y,duration=1)
findImg('./images/word.png')
findImg('./images/HBX.png')
findImg('./images/chrome.png')
pg.doubleClick()
sleep(5)
pg.hotkey("win","shift","q")
pg.alert("脚本运行完毕")