使用python实现GUI自动化期间鼠标未单击
我正在尝试建立一个桌面机器人,它可以自动在社交网站上推广艺术。 现在我只想让鼠标在艺术图像上滚动,一旦心形可见,它就应该点击它。 我制作的节目使用python实现GUI自动化期间鼠标未单击,python,user-interface,error-handling,automation,bots,Python,User Interface,Error Handling,Automation,Bots,我正在尝试建立一个桌面机器人,它可以自动在社交网站上推广艺术。 现在我只想让鼠标在艺术图像上滚动,一旦心形可见,它就应该点击它。 我制作的节目 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
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)
导入pyautogui
i=0
当我<700时:
pyautogui.moveTo(400,i,2)
i+=50
promote=pyautogui.locateOnScreen('heart.JPG'))
x、 y=pyautogui.center(升级)
pyautogui。单击(x,y)
但我得到了一个错误,找不到图像,我已保存图像的权利旁边的程序在目录中。我如何解决这个问题
这就是错误所在
$C:/Users/sultan/AppData/Local/Programs/Python/Python37/Python.exe C:
/Users/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\uuuuu init\uuuuu.py“,第407行,中间
返回(coords[0]+int(coords/2),coords+int(coords[3]/2))
TypeError:“非类型”对象不可下标
将JPG
替换为小写JPG
promote=pyautogui.locateOnScreen('heart.jpg')
文件类型由小写字母定义,而locateOnScreen区分大小写,因此不起作用
尝试过但没有成功,这是错误-C:/Users/sultan/AppData/Local/Programs/Python/Python37/Python.exe C:/Users/sultan/Python/society6-bot.py回溯(最后一次调用):文件“C:/Users/sultan/Python/society6 bot.py”,第7行,在x,y=pyautogui.center(promote)文件中“C:\Users\sultan\AppData\Local\Programs\Python\37\lib\site packages\pyscreeze\u init\uuuz.py”,第407行,中间返回(coords[0]+int(coords[2]/2),coords[1]+int(coords[3]/2))类型错误:“非类型”对象不可订阅