asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.45k stars 1.26k forks source link

locateOnScreen returns none instead of an exception #705

Open andrewjurczynski opened 2 years ago

andrewjurczynski commented 2 years ago

Running the latest version and instead of returning an exception like it should it returns a none value.

jack-ylt commented 2 years ago

why want a None value.

if below can solve your problem?

try: run_some_funcions() except XXX: handle_exception()

targhs commented 2 years ago

why want a None value.

if below can solve your problem?

try: run_some_funcions() except XXX: handle_exception()

I believe that's @andrewjurczynski is saying. It returns 'None' but it should raise an exception.

GiorgsenHub commented 2 years ago

Documentations on this are not correct issue 441 describes the culprit. You can add pyautogui.useImageNotFoundException() after the imports in your code, and that will "fix" the problem you are facing