Actualiser main.py
* Double appuie sur la touche Windows * Quitte quand la souris bouge
This commit is contained in:
parent
0b19fa404e
commit
842253a929
1 changed files with 24 additions and 3 deletions
27
main.py
27
main.py
|
@ -1,11 +1,32 @@
|
|||
from pyautogui import press
|
||||
from pyautogui import press, position
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
|
||||
|
||||
def action():
|
||||
while True:
|
||||
sleep(0.1)
|
||||
press("win")
|
||||
sleep(0.5)
|
||||
press("win")
|
||||
sleep(20)
|
||||
|
||||
|
||||
def wait_mouse():
|
||||
previous_x, previous_y = position()
|
||||
threshold = 50
|
||||
|
||||
while True:
|
||||
position_x, position_y = position()
|
||||
if (abs(position_x - previous_x) > threshold or abs(position_y - previous_y) > threshold):
|
||||
return
|
||||
|
||||
previous_x, previous_y = position_x, position_y
|
||||
sleep(0.1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
action()
|
||||
t = Thread(target=action)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
wait_mouse()
|
||||
|
|
Loading…
Reference in a new issue