0
import pyautogui
import time
from tkinter import Tk  
pyautogui.FAILSAFE = True

clipyy = pyautogui.locateOnScreen('clipy.png')
clipy = pyautogui.center(clipyy)

pyautogui.leftClick(clipy)

This is my code. Could you please find the answer?

I tried the pyautogui.locateOnScreen('clipy.png') but it simply does not work

  • its not pyautogui.leftClick() its pyautogui.click() and you can pass x and y to click method – X-_-FARZA_ D-_-X Jun 25 '23 at 10:49
  • checkout https://pyautogui.readthedocs.io/en/latest/mouse.html#mouse-clicks also check if clipyy has found the img you are looking for then pass it to pyautogui.center() you can place it in an if clause – X-_-FARZA_ D-_-X Jun 25 '23 at 10:51
  • 1. [PyAutoGUI Mouse control](https://pyautogui.readthedocs.io/en/latest/mouse.html#mouse-clicks) 2. [How to detect an image and click it with pyautogui?](https://stackoverflow.com/questions/69864949/how-to-detect-an-image-and-click-it-with-pyautogui) – Nesi Jun 25 '23 at 10:54

1 Answers1

0

try this

import pyautogui

clipyy = pyautogui.locateOnScreen('clipy.png')
if clipyy:
    print("found Image")
    clipy = pyautogui.center(clipyy)
    pyautogui.click(x=clipy.x, y=clipy.y)
else:
    print("Image not found")