0

The code works when it sees the image, however it gives up (an error that says "cannot unpack non-iterable NoneType object") instead of retrying once the image it's looking is affected by certain circumstance like moving a window that blocks the code's view.

This is the code

import pyautogui 

while True:
    x, y = pyautogui.locateCenterOnScreen('icon.png', confidence=0.8)
    print(x, y)

1 Answers1

0

Looks like I found the solution myself by replacing "x, y" by just any letter.

Here is the code that works without receiving errors:

Clicks on the picture:

import pyautogui 

while True:
    f = pyautogui.locateCenterOnScreen('icon.png')
    pyautogui.click(f)

Prints the location of the picture:

#! python3
import pyautogui 

while True:
    f = pyautogui.locateCenterOnScreen('icon.png')
    print(f)