[Python] How can I use pyautogui so that even with 2 screens with different resolutions, a...

Discussão em 'Python' iniciado por Stack, Fevereiro 10, 2025.

  1. Stack

    Stack Membro Participativo

    here's my code:

    import pyautogui

    screen_width, screen_height = pyautogui.size()

    def scale_positions(x, y, base_width=2560, base_height=1440):
    return int(x * screen_width / base_width), int(y * screen_height / base_height)

    pyautogui.moveTo(*scale_positions(1415, 973))


    are goal is to despite the different resolution of 2 screen that a MoveTo with pyautogui is done in the same place but it doesn't work

    I change my resolution (with the nvidia control panel) from 2560x1440 (my native resolution) to 1920x1080 and the cursor isn't in the same place (I've also done the test and pyautogui tells me that my resolution is 1920x1080 when I change it, so it's not because I'm changing it and I don't have a native 1920x1080 screen).

    Continue reading...

Compartilhe esta Página