Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python实现GUI自动化期间鼠标未单击_Python_User Interface_Error Handling_Automation_Bots - Fatal编程技术网

使用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))类型错误:“非类型”对象不可订阅