Python Forum

Full Version: PyAutoGUI issues with detection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all,

I'm experiencing issues with the image recognition tool (pyautogui.locateOnScreen('/Users/kd/Desktop/image.png', confidence=0.8)
I have made a auto clicker script this is the part causing troubles.

        image = pyautogui.locateCenterOnScreen('/Users/kd/Desktop/image.png', confidence=0.8)
        pyautogui.click(x=1180, y=160, clicks=1, interval=1, button='left')
        pyautogui.click(x=1125, y=105, clicks=1, interval=1, button='left')
        time.sleep(3)
        pyautogui.locateOnScreen('/Users/kd/Desktop/image.png', confidence=0.8)
        print(image)

        if image is None:
            pyautogui.click(x=1415, y=105, clicks=1, interval=1, button='left')
            pyautogui.click(x=1165, y=390, clicks=1, interval=1, button='left')
            pyautogui.click(x=1250, y=467, clicks=1, interval=1, button='left')
        else:
            pyautogui.click(image.x / 2, image.y / 2, clicks=1, interval=3, button='left')
            pyautogui.click(x=1122, y=105, clicks=1, interval=1, button='left')
(the coordinate divider is because of a small workaround as my MacBook Pro has higher pixel density and therefore causes problems with the screenshot tool of pyautogui.)
But whenever I try to locate and click the image.png its not detecting anything even when the image is right in the screen.. I have searched a lot on the forums but couldn't find a solution. Was hoping someone could help me out as this has been really frustrating me! How can I let my script recognise the images when the script is running? thanks in advance


EDIT:
The print function also shows that there is no image found even when its right there in the screen.