-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanti_standby.py
39 lines (33 loc) · 1.26 KB
/
anti_standby.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import time
from pynput.mouse import Controller
from pynput.keyboard import Controller as KeyboardController
# Configurazione
INTERVALLO = 60 # Intervallo in secondi tra ogni azione
UTILIZZA_MOUSE = True # True per muovere il mouse, False per premere un tasto innocuo
TASTO_INNOCUO = "shift" # Tasto innocuo da premere se UTILIZZA_MOUSE è False
# Inizializza il controller del mouse e della tastiera
mouse = Controller()
keyboard = KeyboardController()
def muovi_mouse():
"""Muove il mouse impercettibilmente."""
posizione_attuale = mouse.position
# Muove il mouse di 1 pixel a destra e poi torna alla posizione originale
mouse.move(1, 0)
time.sleep(0.1)
mouse.position = posizione_attuale
def premi_tasto():
"""Premi un tasto innocuo."""
keyboard.press(TASTO_INNOCUO)
keyboard.release(TASTO_INNOCUO)
if __name__ == "__main__":
print(f"Script attivo: azione ogni {INTERVALLO} secondi.")
print(f"{'Muovo il mouse' if UTILIZZA_MOUSE else f'Premo il tasto {TASTO_INNOCUO}'} per evitare lo standby.")
try:
while True:
if UTILIZZA_MOUSE:
muovi_mouse()
else:
premi_tasto()
time.sleep(INTERVALLO)
except KeyboardInterrupt:
print("\nScript terminato.")