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.45k stars 1.26k forks source link

[Question] Why is pyautogui mousemovement not recognised by Win10? #748

Open Tech4Ever opened 1 year ago

Tech4Ever commented 1 year ago

Hi,

I used AutoHotKey and the function mousemove() for a while. With hthis code, my windows did not lock and MS Teams e.g. showed me as active:

Loop{ MouseMove, 10, 5, ,R sleep 300000 }

I tried to reproduce this with pyautogui and this code:

`import pyautogui as py import time

while True: py.moveRel(5,10) time.sleep(300)`

I see the mouse moving, but MS Teams shows me as inactive after 5 minutes and after 10 minuters my monitor turns off.

So what´s wrong here?

MiniMitre commented 1 year ago

Hey! so what might be happening is that your mouse is hitting the bottom right corner of the screen (which is a failsafe in PyAutoGui to stop the code if the mouse moves to a corner of the screen).

Possible fix would be to add a py.moveRel(-5,-10) inside the while loop.

Also, the exact Windows sleep settings of your machine will change the outcome, so double check those as well.

Tech4Ever commented 1 year ago

Hi,

I can confirm that PYAutoGui failsafe is not the reason why it is not working! As you can see the mouse is moving every 5 minutes only 10 and 5 pixels and it did defintely not hit any corner of the screen in that time. And after 5 minutes monitor turns off. As I mentioned, with Autohotkey I have no problems. I really want to understand why it´s not workig in PyAutoGui because I can see the mouse is moving, but it seems to be not recogised by windows!