Python Forum
PyAutoGUI issues with detection
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyAutoGUI issues with detection
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Please help me in regards to pyAutoGUI andrewtuk 2 1,467 Jan-01-2023, 05:22 PM
Last Post: gradlon93
  How can I loop PyAutoGUI's locateCenterOnScreen until the image is found? Tiel 2 7,709 Sep-26-2021, 09:39 AM
Last Post: Tiel
  pyautogui attribuyes not found rfresh737 7 3,053 Apr-14-2021, 01:32 AM
Last Post: rfresh737

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020