circle to prevent sleeping
This commit is contained in:
parent
beb80dfdc6
commit
f8fcd2631f
4 changed files with 42 additions and 9 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
bin/
|
||||||
|
lib/
|
||||||
|
|
||||||
|
pyvenv.cfg
|
|
@ -1,7 +1,7 @@
|
||||||
# Never away
|
# Never away
|
||||||
|
|
||||||
Appuie régulièrement sur la touche Windows
|
Appuie régulièrement sur la touche Windows, tout en faisant tourner la souris
|
||||||
|
|
||||||
> `pip install pyautogui`
|
> `pip install -r requirements.txt`
|
||||||
|
|
||||||
Pour stopper le programme, bouger la souris
|
Pour stopper le programme, bougez amplement la souris
|
||||||
|
|
38
main.py
38
main.py
|
@ -1,6 +1,7 @@
|
||||||
from pyautogui import press, position
|
from pyautogui import moveTo, size as screen_size, press, position
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from math import radians, cos, sin
|
||||||
|
|
||||||
|
|
||||||
def action():
|
def action():
|
||||||
|
@ -17,16 +18,41 @@ def wait_mouse():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
position_x, position_y = position()
|
position_x, position_y = position()
|
||||||
if (abs(position_x - previous_x) > threshold or abs(position_y - previous_y) > threshold):
|
if (
|
||||||
|
abs(position_x - previous_x) > threshold
|
||||||
|
or abs(position_y - previous_y) > threshold
|
||||||
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
previous_x, previous_y = position_x, position_y
|
previous_x, previous_y = position_x, position_y
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def circle(radius, base_x, base_y, wait):
|
||||||
t = Thread(target=action)
|
sleep(wait)
|
||||||
t.daemon = True
|
while True:
|
||||||
t.start()
|
for angle in range(0, 360, 5):
|
||||||
|
x = base_x + radius * cos(radians(angle))
|
||||||
|
y = base_y + radius * sin(radians(angle))
|
||||||
|
|
||||||
|
moveTo(x, y)
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Win key
|
||||||
|
t1 = Thread(target=action)
|
||||||
|
t1.daemon = True
|
||||||
|
t1.start()
|
||||||
|
|
||||||
|
wait = 5
|
||||||
|
|
||||||
|
# Circle mouse
|
||||||
|
t2 = Thread(
|
||||||
|
target=circle, args=(100, screen_size()[0] // 2, screen_size()[1] // 2, wait)
|
||||||
|
)
|
||||||
|
t2.daemon = True
|
||||||
|
t2.start()
|
||||||
|
|
||||||
|
sleep(wait + 2)
|
||||||
wait_mouse()
|
wait_mouse()
|
||||||
|
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pyautogui==0.9.54
|
Loading…
Reference in a new issue