所以我制作了一个程序,当它们出现时,可以检测图像并点击它们,但它工作正常,但有一天(IDK,如果我删除了一些我不应该做的事情),但是现在在屏幕上没有图像时会引发异常。
[代码和异常][1]
代码很简单:
import pyautogui
location1 = pyautogui.locateCenterOnScreen('velaki.png')
print(location1)
然后错误是:
Traceback (most recent call last):
File "C:\Users\Patroklos\Desktop\FoE\taxini.PY", line 3, in
location1 = pyautogui.locateCenterOnScreen('velaki.png')
File "C:\Python34\lib\site-packages\pyscreeze\__init__.py", line 300, in locateCenterOnScreen
coords = locateOnScreen(image, **kwargs)
File "C:\Python34\lib\site-packages\pyscreeze\__init__.py", line 271, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File "C:\Python34\lib\site-packages\pyscreeze\__init__.py", line 255, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
File "C:\Python34\lib\site-packages\pyscreeze\__init__.py", line 249, in _locateAll_python
raise ImageNotFoundException('Could not locate the image.')
pyscreeze.ImageNotFoundException: Could not locate the image.
正常情况下,如果没有找到图像,则返回none。