在python的GUI自动化过程中鼠标不点击

2024-06-01 04:04:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图建立一个桌面机器人,自动促进社会6的艺术。 现在,我只想鼠标滚动,然后艺术形象,一旦心的形状是可见的,那么它应该点击它。 page on which I want my program to run

Image which i want to click on

我制作的程序

import pyautogui
i = 0
while i < 700:
 pyautogui.moveTo(400,i,2)
 i += 50
 promote = pyautogui.locateOnScreen('heart.JPG')
 x, y = pyautogui.center(promote)
 pyautogui.click(x,y)

但我得到一个错误,找不到图像,我已经保存了图像旁边的程序在目录中。如何解决这个问题?你知道吗

这就是错误 $C:/Users/sultan/AppData/Local/Programs/Python/Python37/python.exec类: /用户/sultan/python/society6-bot.py公司 回溯(最近一次呼叫): 文件“c:/Users/sultan/python/society6-bot.py公司,第7行,在 x、 y=pyautogui.center中心(提升) 文件“C:\Users\sultan\AppData\Local\Programs\Python\Python37\lib\site- packages\pyscreeze\uuuu init\uuuuu.py“,第407行,中间 return(坐标[0]+int(坐标2/2),坐标1+int(坐标[3]/2)) TypeError:“NoneType”对象不可订阅


Tags: topy图像程序whichon错误users