>>> list(pyautogui.locateAllOnScreen("test.png"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 257, in _locateAll_opencv
raise ImageNotFoundException('Could not locate the image (highest confidence = %.3f)' % result.max())
pyscreeze.ImageNotFoundException: Could not locate the image (highest confidence = 0.178)
While locateOnScreen raises pyautogui.ImageNotFoundException correctly:
>>> pyautogui.locateOnScreen("test.png")
Traceback (most recent call last):
File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyautogui\__init__.py", line 172, in wrapper
return wrappedFunction(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyautogui\__init__.py", line 210, in locateOnScreen
return pyscreeze.locateOnScreen(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 405, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 383, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 257, in _locateAll_opencv
raise ImageNotFoundException('Could not locate the image (highest confidence = %.3f)' % result.max())
pyscreeze.ImageNotFoundException: Could not locate the image (highest confidence = 0.167)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyautogui\__init__.py", line 174, in wrapper
raise ImageNotFoundException # Raise PyAutoGUI's ImageNotFoundException.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyautogui.ImageNotFoundException
I guess the problem is that locateAll returns a generator, hence you have to wrap its __next__ method to catch the error, or use yield from.
While
locateOnScreen
raisespyautogui.ImageNotFoundException
correctly:I guess the problem is that
locateAll
returns a generator, hence you have to wrap its__next__
method to catch the error, or useyield from
.