You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. The code is good, and I thought that it could also be ported to the Windows platform. Here is the code I created using OpenAI, it would be great to have protection not only on Linux systems.
As a modification, I added a function that tracks the keyboard (let's say we play the game exclusively on the keyboard). This allows you to reduce the number of unnecessary actions.
I didn’t create my own repository/code (I’m new to this environment, I have no idea how or what’s going on here)
so I think you should have this in your repository.
import time
import pyautogui
from plyer import notification
import threading
from pynput import keyboard
program_name = "Lockigest"
wait_time = 25
countdown = 25
X, Y = 0, 0
PML_X, PML_Y = 0, 0
counter = 0
protection = 0
keyboard_active = True
mouse_active = True
key_count = 0
PML_keyboard = 0
def toggle_protection(status):
global protection
protection = status
if status == 1:
print("\t Protection mode was activated.")
else:
print("\t Protection mode was deactivated.")
def lock_screen():
# Lock the screen (this is platform-dependent)
import ctypes
ctypes.windll.user32.LockWorkStation()
def on_press(key):
global keyboard_active, key_count
keyboard_active = True
key_count += 1
def monitor_mouse():
global X, Y, PML_X, PML_Y, counter, protection, keyboard_active, mouse_active, key_count, PML_keyboard
while True:
time.sleep(0.2)
X, Y = pyautogui.position()
if mouse_active or keyboard_active:
mouse_active = False
keyboard_active = False
counter = 0
continue
if (X != PML_X or Y != PML_Y) or (key_count != PML_keyboard):
PML_X, PML_Y = X, Y
PML_keyboard = key_count
counter = 0
if protection == 1:
while counter != countdown:
time.sleep(0.2)
X, Y = pyautogui.position()
counter += 1
print(f"({counter}/{countdown})\t Move your cursor to the specified area.")
if ((Y == 0)):
toggle_protection(0)
key_count = 0
break
if protection == 1:
print("\t\t The device was locked.")
toggle_protection(0)
key_count = 0
lock_screen()
else:
counter += 1
keyboard_active = False
print(f"({counter}/{wait_time})\t The cursor is inactive. X: {X} Y: {Y}")
if counter >= wait_time and protection == 0:
toggle_protection(1)
def start_key_listener():
with keyboard.Listener(on_press=on_press) as listener:
listener.join()
if __name__ == "__main__":
key_listener_thread = threading.Thread(target=start_key_listener, daemon=True)
key_listener_thread.start()
monitor_mouse()
The text was updated successfully, but these errors were encountered:
Hello. The code is good, and I thought that it could also be ported to the Windows platform. Here is the code I created using OpenAI, it would be great to have protection not only on Linux systems.
As a modification, I added a function that tracks the keyboard (let's say we play the game exclusively on the keyboard). This allows you to reduce the number of unnecessary actions.
I didn’t create my own repository/code (I’m new to this environment, I have no idea how or what’s going on here)
so I think you should have this in your repository.
The text was updated successfully, but these errors were encountered: