欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

python pyautogui 打地鼠游戏 视频代码 自己亲自做的代码 有大用 有大大用

#首先得先安装如下的三个包
#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('没找到')



来自  https://www.bilibili.com/video/BV1844y1N7xH/?vd_source=346847773d1f74962a4daab9ddf7f228 


下面的两个附件是自己亲自做的代码

附件大小
Package icon pyautogui.zip29.58 KB
Package icon pyautogui_study.zip4.7 KB
普通分类: