forked from Grow-with-Open-Source/Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_clicker.py
More file actions
49 lines (37 loc) · 1.09 KB
/
auto_clicker.py
File metadata and controls
49 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pyautogui
import keyboard
import time
def run_auto_clicker(delay: float = 0.01) -> None:
"""
Runs an auto clicker that can be controlled with keyboard hotkeys.
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():
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)
if keyboard.is_pressed("q"):
print("👋 Exiting program")
break
except KeyboardInterrupt:
print("\nProgram interrupted by user.")
if __name__ == "__main__":
run_auto_clicker()