-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.py
More file actions
34 lines (28 loc) · 993 Bytes
/
Copy pathhandler.py
File metadata and controls
34 lines (28 loc) · 993 Bytes
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
import time
import pyautogui
from typing import Optional
class ClickHandler:
"""Handles click operations and event timing."""
def __init__(self, interval: float = 0.1):
self.interval = interval
self.running = False
def start_clicking(self) -> None:
"""Initiates the main clicking sequence."""
self.running = True
try:
while self.running:
pyautogui.click()
time.sleep(self.interval)
except KeyboardInterrupt:
self.stop_clicking()
def stop_clicking(self) -> None:
"""Gracefully halts the click loop."""
self.running = False
def set_interval(self, new_interval: float) -> None:
"""Updates the click delay duration."""
if new_interval > 0:
self.interval = new_interval
if __name__ == "__main__":
handler = ClickHandler(interval=0.5)
print("Starting autoclicker (Ctrl+C to stop)...")
handler.start_clicking()