I'm having a problem with if statement when checking if value matches. The intention is to check for the resolution of the screen and then accordingly use predefined coordinates (with the relation to the resoulution) to click with pyautogui so the script can be run on displays with differing resoulutions.
This is the code:
import pyautogui
screenWidth, screenHeight = pyautogui.size()
if (screenWidth == 1920, screenHeight == 1080):
click1 = 780, 150
click2 = 150, 120
click3 = 450, 120
if (screenWidth == 1366, screenHeight == 768):
click1 = 650, 120
click2 = 120, 100
click3 = 350, 100
if (screenWidth == 1360, screenHeight == 768):
click1 = 650, 120
click2 = 120, 100
click3 = 350, 100
if (screenWidth == 1280, screenHeight == 800):
click1 = 630, 110
click2 = 120, 90
click3 = 350, 90
if (screenWidth == 1280, screenHeight == 768):
click1 = 630, 120
click2 = 120, 90
click3 = 350, 100
print(screenWidth,screenHeight)
print(click1,click2,click3)
and this is the output which is not what is given above for 1080p:
1920 1080
(630, 120) (120, 90) (350, 100)
Also the message "redeclared click1 defined above without ussage" appears Is there something I'm missing with the code?
Aucun commentaire:
Enregistrer un commentaire