Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to click on center of image in pyautogui

I want to click on the center of the image so what can I do I'm tired to click on the centre of the image in pyautogui

For Example for an image we need to write this:

pyautogui.locateOnScreen('image.png')

How Can I locate the center of the image?

like image 200
Hamza Lachi Avatar asked Dec 13 '25 15:12

Hamza Lachi


1 Answers

You can directly find the center of the image using the built in locateCenterOnScreen method.

locateCenterOnScreen(image, grayscale=False)

Returns (x, y) coordinates of the center of the first found instance of the image on the screen. Raises ImageNotFoundException if not found on the screen.

like image 165
CodeIt Avatar answered Dec 15 '25 07:12

CodeIt