Untitled
unknown
plain_text
a year ago
3.0 kB
6
Indexable
def kill_switch(): global running while running: if pyautogui.keyDown(kill_switch_key.get()): running = False break time.sleep(0.1) def pause_resume(): global paused paused = not paused pause_button.config(text="Resume" if paused else "Pause", command=pause_resume) def update_config(): global min_alt_tab_delay, max_alt_tab_delay, min_mouse_delay, max_mouse_delay, randomize_xy, kill_switch_key try: min_alt_tab_delay.set(int(alt_tab_delay_entry.get())) max_alt_tab_delay.set(int(alt_tab_delay_max_entry.get())) min_mouse_delay.set(int(mouse_delay_entry.get())) max_mouse_delay.set(int(mouse_delay_max_entry.get())) randomize_xy.set(randomize_var.get()) kill_switch_key.set(kill_switch_entry.get()) if validate_config({ "min_alt_tab_delay": min_alt_tab_delay.get(), "max_alt_tab_delay": max_alt_tab_delay.get(), "min_mouse_delay": min_mouse_delay.get(), "max_mouse_delay": max_mouse_delay.get(), "randomize_xy": randomize_xy.get(), "kill_switch_key": kill_switch_key.get() }): save_config({ "min_alt_tab_delay": min_alt_tab_delay.get(), "max_alt_tab_delay": max_alt_tab_delay.get(), "min_mouse_delay": min_mouse_delay.get(), "max_mouse_delay": max_mouse_delay.get(), "randomize_xy": randomize_xy.get(), "kill_switch_key": kill_switch_key.get() }, "config.json") except ValueError as e: logging.error(f"Invalid user input during configuration update: {e}") messagebox.showerror("Error", "Invalid configuration values. Please check your input.") def main(): global running, paused, min_alt_tab_delay, max_alt_tab_delay, min_mouse_delay, max_mouse_delay, randomize_xy, kill_switch_key if len(sys.argv) != 2: print("Usage: python script.py <duration>") return duration = parse_duration(sys.argv[1]) # Load configuration (default to config.json) config = load_config("config.json") # Initialize Tkinter window and variables window = Tk() window.title("Script Controller") min_alt_tab_delay = IntVar(value=config["min_alt_tab_delay"]) max_alt_tab_delay = IntVar(value=config["max_alt_tab_delay"]) min_mouse_delay = IntVar(value=config["min_mouse_delay"]) max_mouse_delay = IntVar(value=config["max_mouse_delay"]) randomize_var = BooleanVar(value=config["randomize_xy"]) kill_switch_key = StringVar(value=config["kill_switch_key"]) running = True paused = False # Create GUI elements # ... (code for creating labels, entry fields, buttons using the variables) # Start/Stop and Pause/Resume functionality # ... (code for start_button, pause_button functionality using running and paused flags) window.protocol("WM_DELETE_WINDOW", window.quit) # Close threads on window close window.mainloop() # Stop threads on exit running = False alt_tab_thread.join() mouse_move_thread.join() kill_switch_thread.join() if __name__ == "__main__": import sys main()
Editor is loading...
Leave a Comment