Graham
Graham

Reputation: 21

Pyautogui not clicking on exact location

I am trying to get my pyautogui setup. The only code I have in it right now is to move the mouse to one location then move it to another. I am also on windows running a 2k monitor. The problem is I set the move to move to x=1235, y=120 but the mouse actually moves to 988, 96 and when I set it to move to x=1650, y=315 the mouse then moves to 1320, 252. I have not found any answers for this yet. Here is the code:

(main.py)

import pyautogui
from mainFunctions import *
moveCharacter()

(mainFunctions.py)

import pyautogui
import time
def moveCharacter():
    pyautogui.moveTo(x=1235 , y=120)
    time.sleep(1)
    pyautogui.moveTo(x=1650, y=315)

Upvotes: 1

Views: 1261

Answers (1)

EasyWay Coder
EasyWay Coder

Reputation: 341

That can be because of either of the two: You change your screen resolution OR It's because of pyautogui's FAILSAFE system.

If you haven't changed your screen resolution, then try this code in your mainFunctions.py file:

from pyautogui import *
from time import *
def moveCharacter():
    FAILSAFE = False
    moveTo(x=1235 , y=120)
    sleep(1)
    moveTo(x=1650, y=315)

Upvotes: 1

Related Questions