#首先得先安装如下的三个包#pip3 install pyautogui
#pip3 install pillow
#pip3 install opencv-python #但是我这边说没有找到这个包,只有科学才可以安装这个包
import pyautogui
pyautogui.PAUSE = 0.1
pyautogui.FAILSAFE = True
while True:
coords = pyautogui.locateOnScreen('E:/pydemo/demo/image/image.jpg',confidence=0.8)
if coords is not None :
print('找到了,进行点击')
x,
y =
pyautogui.center(
coords) #似乎新版的当中没有 center函数了,
locateOnScreen和center用 locateCenterOnScreen 来代替吧 见 /node-admin/20889
pyautogui.leftclick(x,y)
pyautogui.moveTo(1223, 503)#移动到左上角,防止同一个洞连续两次出现老鼠头的时候,点击失效
else:
print('没找到')