-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoclicker.py
57 lines (39 loc) · 1.09 KB
/
autoclicker.py
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
50
51
52
53
54
55
56
57
import pyautogui
from pynput.keyboard import Key, Listener
# ======== Controls ========
start_or_pause_key = Key.f1
exit_key = Key.esc
delay = 1 # seconds
# ==== global variables ====
pause = True
running = True
def display_controls():
print("F1 = Start / Pause")
print("ESC = Exit\n")
def choose_delay():
try:
return float(input("Enter wanted delay (seconds): "))
except ValueError:
print(f"You did not give a valid input, default delay : {delay}sec")
return delay
def key_press(key):
global running, pause
if key == start_or_pause_key:
pause = not pause
print("< Pause >") if pause else print("< Start >")
elif key == exit_key:
running = False
print("< Exit >")
def main():
delay = choose_delay()
print(f"delay = {str(delay)}sec\n")
display_controls()
listener = Listener(on_press=key_press)
listener.start()
while running:
if not pause:
pyautogui.click(pyautogui.position())
pyautogui.PAUSE = delay
listener.stop()
if __name__ == "__main__":
main()