-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJiggle.py
78 lines (51 loc) · 1.89 KB
/
Jiggle.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import multiprocessing
import sys
import time
from datetime import datetime
import pyautogui
import keyboard
import random
pyautogui.FAILSAFE = False
width, height= pyautogui.size()
def jiggle(sleepTime):
while(True):
time.sleep(sleepTime)
x = random.randint(-500,500)
y = random.randint(-500,500)
print(x,y)
pyautogui.move(x, y, 1, pyautogui.easeInOutQuad)
pyautogui.moveTo(width/2,height/2, 0.5, pyautogui.easeInOutQuad)
print("Mouse movement made at {}".format(datetime.now().time()))
def keyChecker(q):
recorded = keyboard.record(until="esc")
print(recorded)
if (recorded != None):
print("Esc pressed")
print("KILL JIGGLE!!!")
q.put("KILL JIGGLE")
def main():
q = multiprocessing.Queue()
sleepTime = int(input("Enter the jiggle period in seconds:"))
print("To end the program press esc")
print("Starting to jiggle in {} seconds!".format(sleepTime))
ProcessJiggle = multiprocessing.Process(target=jiggle, args=(sleepTime,))
ProcessKeyChecker = multiprocessing.Process(target=keyChecker, args=(q,))
ProcessKeyChecker.daemon = True
ProcessJiggle.start()
ProcessKeyChecker.start()
while True:
msg = q.get()
if msg == "KILL JIGGLE":
print("Terminating...")
ProcessJiggle.terminate()
time.sleep(0.1)
if not ProcessJiggle.is_alive():
ProcessJiggle.join(timeout=1.0)
print("Joined successfully")
print("Jiggle process terminated!")
q.close()
break
print("End of jiggling :(")
sys.exit()
if __name__ == "__main__":
main()