Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 36 additions & 21 deletions Auto-Clicker/auto_clicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,48 @@
import keyboard
import time

clicking = False

def run_auto_clicker(delay: float = 0.01) -> None:
"""
Runs an auto clicker that can be controlled with keyboard hotkeys.

def start_clicking():
global clicking
clicking = True
print("Auto clicker started")
Controls:
- Press 'S' to start clicking
- Press 'E' to stop clicking
- Press 'Q' to quit
"""
clicking = False

def start_clicking():
nonlocal clicking
clicking = True
print("✅ Auto clicker started")

def stop_clicking():
global clicking
clicking = False
print("Auto clicker stopped")
def stop_clicking():
nonlocal clicking
clicking = False
print("⏹ Auto clicker stopped")

keyboard.add_hotkey("s", start_clicking)
keyboard.add_hotkey("e", stop_clicking)

print("Press 'S' to start clicking")
print("Press 'E' to stop clicking")
print("Press 'Q' to quit")

try:
while True:
if clicking:
pyautogui.click()
time.sleep(delay)

keyboard.add_hotkey("s", start_clicking)
keyboard.add_hotkey("e", stop_clicking)
if keyboard.is_pressed("q"):
print("👋 Exiting program")
break

print("Press 'S' to start clicking")
print("Press 'E' to stop clicking")
print("Press 'Q' to quit")
except KeyboardInterrupt:
print("\nProgram interrupted by user.")

while True:
if clicking:
pyautogui.click()
time.sleep(0.001)

if keyboard.is_pressed("q"):
print("Exiting program")
break
if __name__ == "__main__":
run_auto_clicker()