143 lines
4.1 KiB
Python
Executable File
143 lines
4.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from os import system
|
|
from os import name
|
|
import pyautogui
|
|
import threading
|
|
import datetime
|
|
from random import randint
|
|
import subprocess
|
|
|
|
_debug = False
|
|
|
|
time_between_moves = 1.0 # How long between each move (in seconds)
|
|
move_duration = 0.1 # How long a move to the next coordinate should take (in seconds)
|
|
|
|
screenSize = pyautogui.size()
|
|
idle_time_max = 0
|
|
idle_time_seconds = 0
|
|
previous_idle_time = 0
|
|
moves = 0
|
|
|
|
def banner():
|
|
print("\n")
|
|
print("\t ▄█ █▄ ▄█ ▄██████▄ ▄██████▄ ▄█ ▄██ ▄ ")
|
|
print("\t███ ███ ███ ███ ███ ███ ███ ███ ███ ██▄ ")
|
|
print("\t███ ███ ███▌ ███ █▀ ███ █▀ ███ ███▄▄▄███ ")
|
|
print("\t███ ███ ███▌ ▄███ ▄███ ███ ▀▀▀▀▀▀███ ")
|
|
print("\t███ ███ ███▌ ▀▀███ ████▄ ▀▀███ ████▄ ███ ▄██ ███ ")
|
|
print("\t███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ")
|
|
print("\t███ ▄█▄ ███ ███ ███ ███ ███ ███ ███▌ ▄ ███ ███ ")
|
|
print("\t ▀███▀███▀ █▀ ████████▀ ████████▀ █████▄▄██ ▀█████▀ ")
|
|
print("\t ▀ ")
|
|
print("\n\t_____________________________________________\n\n")
|
|
|
|
def clear():
|
|
# for windows
|
|
if name == 'nt':
|
|
_ = system('cls')
|
|
|
|
# for mac and linux(here, os.name is 'posix')
|
|
else:
|
|
_ = system('clear')
|
|
|
|
def rand_x():
|
|
return randint(1, screenSize[0])
|
|
|
|
def rand_y():
|
|
return randint(1, screenSize[1])
|
|
|
|
def moveMouse():
|
|
global moves
|
|
moves += 1
|
|
x = rand_x()
|
|
y = rand_y()
|
|
pyautogui.moveTo(x, y, duration = move_duration)
|
|
main()
|
|
|
|
def get_idle_time():
|
|
"""Gets the idle time of the current user in seconds."""
|
|
|
|
output = subprocess.check_output(
|
|
"ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000)}'",
|
|
shell=True,
|
|
text=True
|
|
)
|
|
return int(output)
|
|
|
|
def doNothing():
|
|
main()
|
|
|
|
def clear_line(number):
|
|
print(f"\033[{number};0H\033[K\033[A")
|
|
|
|
def main():
|
|
global _debug
|
|
global moves
|
|
global idle_time_max
|
|
global previous_idle_time
|
|
global idle_time_seconds
|
|
|
|
cond = 0
|
|
max_set = 0
|
|
|
|
hour = datetime.datetime.now().hour
|
|
machine_idle_time_seconds = get_idle_time()
|
|
|
|
if previous_idle_time > machine_idle_time_seconds and previous_idle_time <= 118: # Reset
|
|
cond = 1
|
|
idle_time_seconds = machine_idle_time_seconds
|
|
else:
|
|
cond = 2
|
|
idle_time_seconds += 1
|
|
|
|
if idle_time_seconds > idle_time_max:
|
|
max_set = 1
|
|
idle_time_max = idle_time_seconds
|
|
|
|
it_hours = idle_time_seconds // (60 * 60)
|
|
it_s_remains = idle_time_seconds % (60 * 60)
|
|
it_minutes = it_s_remains // 60
|
|
it_seconds = it_s_remains % 60
|
|
|
|
itm_hours = idle_time_max // (60 * 60)
|
|
itm_s_remains = idle_time_max % (60 * 60)
|
|
itm_minutes = itm_s_remains // 60
|
|
itm_seconds = itm_s_remains % 60
|
|
|
|
clear_line(16)
|
|
print(f"\tIdle time: {it_hours}h {it_minutes}m {it_seconds}s",end="\r")
|
|
|
|
clear_line(17)
|
|
print(f"\tIdle time max: {itm_hours}h {itm_minutes}m {itm_seconds}s",end="\r")
|
|
|
|
clear_line(18)
|
|
print(f"\tMoves: {moves}",end="\r")
|
|
|
|
if _debug is True:
|
|
clear_line(15)
|
|
print(f"\tMachine Idle time: {machine_idle_time_seconds} seconds",end="\r")
|
|
|
|
clear_line(20)
|
|
print(f"\tPrevious Idle Time:: {previous_idle_time}",end="\r")
|
|
|
|
clear_line(21)
|
|
print(f"\tcondition hit: {cond}",end="\r")
|
|
|
|
clear_line(22)
|
|
print(f"\tmax updated: {max_set}",end="\r")
|
|
|
|
previous_idle_time = machine_idle_time_seconds
|
|
|
|
if hour == 21:
|
|
print("end of day reached")
|
|
quit()
|
|
elif machine_idle_time_seconds >= 120:
|
|
threading.Timer(time_between_moves, moveMouse).start()
|
|
else:
|
|
threading.Timer(time_between_moves, doNothing).start()
|
|
|
|
clear()
|
|
banner()
|
|
main()
|