** Python pyautogui's click and moveTo functions not working ! **
I am running these codes from VSCode.
Import pyautogui
from time import sleep
sleep(1)
print(pyautogui.position())
sleep(1)
pyautogui.moveTo(0,0,2) # moves mouse to (0,0) over 2 seconds
pyautogui.click(0, 0)
sleep(1)
print(pyautogui.position())
Output:
Point(x=1084, y=167)
Point(x=1084, y=167)
Did not touch the mouse while the program is running.
The position of the mouse cursor was printed out correctly, but the mouse cursor do not move to the new location (0,0) but stays where it was.
Any help will be greatly appreciated.
Python 3.8.8 installed with pyobjc and pyobjc-core. OS : macOS Big Sur VSCode 1.58
You can just use a separate library called
pynput. You can install it withpip3 install pynput. I was facing the same issue the other day and I usedpynputto fix it. Their documentation is pretty good as well.