-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (34 loc) · 996 Bytes
/
main.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
40
41
42
import pyautogui
import time
import sys
pyautogui.FAILSAFE = True
class MouseJiggler:
def __init__(self):
self.x = 0
self.y = 0
def update_coor(self) -> None:
self.x, self.y = pyautogui.position()
def detect_user(self) -> bool:
temp_x, temp_y = pyautogui.position()
if temp_x != self.x and temp_y != self.y:
return True
else:
return False
def jiggle_mouse(self) -> None:
try:
while True:
self.update_coor()
pyautogui.moveRel(10, 0)
time.sleep(1)
if self.detect_user():
time.sleep(30)
pyautogui.moveRel(-10, 0)
time.sleep(1)
if self.detect_user():
time.sleep(30)
sys.stdout.flush()
except KeyboardInterrupt:
print("\n")
if __name__ == "__main__":
mj = MouseJiggler()
mj.jiggle_mouse()