Pyautogui clicks but it wont move the mouse
Question:
Pyautogui wont move the mouse but it will click just fine. I have tried adding the Terminal & python to permissions for taking over the computer, I have tried the drag options and setting coordinates manual. Nothing seems to work, its very frustrating. I’m on a new apple m1 chip, I doubt that is doing it but I thought I would mention it. Any help would be awesome!
def traffic(self):
time.sleep(0.5)
traffic = pyautogui.locateOnScreen('./Traffic.png', confidence=0.9)
pyautogui.moveTo(traffic, duration=1)
time.sleep(0.8)
pyautogui.click(clicks=2, interval=0.5)
Answers:
The reason it does not move is because Traffic.png
is not found, which returns None, which makes the mouse not move anywhere. To make sure the computer finds it, do a little print(traffic)
after the locateOnScreen()
. To increase the likelihood of finding the image, try setting it to grayscale and lowering the confidence value.
I had the same problem as you, all you need to do is run python as administrator, like this comment if you find it helpful
Pyautogui wont move the mouse but it will click just fine. I have tried adding the Terminal & python to permissions for taking over the computer, I have tried the drag options and setting coordinates manual. Nothing seems to work, its very frustrating. I’m on a new apple m1 chip, I doubt that is doing it but I thought I would mention it. Any help would be awesome!
def traffic(self):
time.sleep(0.5)
traffic = pyautogui.locateOnScreen('./Traffic.png', confidence=0.9)
pyautogui.moveTo(traffic, duration=1)
time.sleep(0.8)
pyautogui.click(clicks=2, interval=0.5)
The reason it does not move is because Traffic.png
is not found, which returns None, which makes the mouse not move anywhere. To make sure the computer finds it, do a little print(traffic)
after the locateOnScreen()
. To increase the likelihood of finding the image, try setting it to grayscale and lowering the confidence value.
I had the same problem as you, all you need to do is run python as administrator, like this comment if you find it helpful