Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

X,Y Coordinates Convert

I have written a program in which I am using pyautogui for autoclicking

My code

import pyautogui, time

time.sleep(5.5)
pyautogui.click(x=443, y=178)
time.sleep(0.5)

but the x, y coordinates which I am using are according to my monitor size which is 1920×1080

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My Question:
The x, y coordinates are according to 1920×1080 I want to change them in 1280×720 so that it supports on any monitor resolution.
I wonder I can do that using numpy if yes then how?….if no then is there any other way to do it?….
Any help would be appreciated

Thank You

Regards

>Solution :

Hope this helps:

import pyautogui, time

xCoef = 1280/1920
yCoef = 720/1080


def clickFunc(x,y):
    pyautogui.click(x=int(xCoef*x), y=int(y*yCoef))


time.sleep(5.5)
clickFunc(443,178)
time.sleep(0.5)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading