-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (36 loc) · 1.3 KB
/
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 as pa
import datetime as dt
import threading
def inputChecker():
# Create a thread to run the main loop
thread = threading.Thread(target=mouseMover)
thread.start()
# Wait for enter key to be pressed
input()
# Set the flag to stop the main loop
global running
running = False
# Wait for the main loop to finish
thread.join()
print("\033[Fkeep_awake stopped.")
def mouseMover():
startMoveTime = dt.datetime.now()
endMoveTime = startMoveTime + dt.timedelta(minutes=4, seconds=30)
# endMoveTime = startMoveTime + dt.timedelta(seconds=1)
global running
running = True
sign = -1
while running:
secondsDifference = round((dt.datetime.now() - endMoveTime).total_seconds())
if secondsDifference == 0:
pa.moveRel(0, sign * 1)
sign = sign * -1
startMoveTime = endMoveTime
endMoveTime = startMoveTime + dt.timedelta(minutes=4, seconds=30)
# endMoveTime = startMoveTime + dt.timedelta(seconds=1)
roundedTime = startMoveTime.replace(microsecond=0)
print(f'Mouse moved at {roundedTime}.')
if __name__ == '__main__':
print('keep_awake has started.')
print('Press enter to stop')
inputChecker()