one dot oh

Signed-off-by: kkenny <kkenny379@gmail.com>
This commit is contained in:
kkenny 2025-01-10 16:59:39 -05:00
parent 35e30552fd
commit 4cf5a4e2e4
1 changed files with 116 additions and 36 deletions

152
main.py
View File

@ -1,62 +1,142 @@
#!/usr/bin/env python #!/usr/bin/env python
from os import system
from os import name
import pyautogui import pyautogui
import threading import threading
import datetime import datetime
from random import randint from random import randint
import subprocess import subprocess
time_between_moves = 5.0 # How long between each move (in seconds) _debug = False
move_duration = 1 # How long a move to the next coordinate should take (in seconds)
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() screenSize = pyautogui.size()
idle_time_max = 0
idle_time_seconds = 0
previous_idle_time = 0
moves = 0
def get_idle_time(): def banner():
"""Gets the idle time of the current user in seconds.""" 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")
output = subprocess.check_output( def clear():
"ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000)}'", # for windows
shell=True, if name == 'nt':
text=True _ = system('cls')
)
return int(output) # for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
def rand_x(): def rand_x():
return randint(1, screenSize[0]) return randint(1, screenSize[0])
def rand_y(): def rand_y():
return randint(1, screenSize[1]) return randint(1, screenSize[1])
def moveMouse(): def moveMouse():
x = rand_x() global moves
y = rand_y() moves += 1
pyautogui.moveTo(x, y, duration = move_duration) x = rand_x()
main() y = rand_y()
pyautogui.moveTo(x, y, duration = move_duration)
main()
#def clickMouse(): def get_idle_time():
# pyautogui.click() """Gets the idle time of the current user in seconds."""
# main()
output = subprocess.check_output(
"ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000)}'",
shell=True,
text=True
)
return int(output)
def doNothing(): def doNothing():
main() main()
def clear_line(number):
print(f"\033[{number};0H\033[K\033[A")
def main(): def main():
hour = datetime.datetime.now().hour global _debug
idle_time_seconds = get_idle_time() global moves
print(f"Idle time: {idle_time_seconds} seconds") global idle_time_max
global previous_idle_time
global idle_time_seconds
if hour == 18: cond = 0
print("end of day reached") max_set = 0
quit()
elif idle_time_seconds >= 15:
threading.Timer(time_between_moves, moveMouse).start()
# threading.Timer(10.0, clickMouse).start()
else:
threading.Timer(time_between_moves, doNothing).start()
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() main()