asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.47k stars 1.27k forks source link

bug: pyautogui.moveTo method does not work when desktop has no application opened (windows) #841

Open szetakyu opened 9 months ago

szetakyu commented 9 months ago

I know it sound strange. But it is true. I use vscode to run the test.

Case1: If i run the script, the cursor will move to x,y.

Case2: If i start the script then minimize everything (no other application opened on desktop), the cursor will NOT move to x,y.

Case3: If i start the script then minimize vscode (leaving a opened notepad), the cursor will move to x,y.

Why is this happening?

Below it is test code I used.

import time
import pyautogui

time.sleep(3)
x = 100
y = 100
pyautogui.moveTo(x,y)