-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclicker.py
executable file
·52 lines (46 loc) · 1.18 KB
/
clicker.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
# Running:
# python clicker.py [clicking interval]
from pynput.mouse import Button, Controller # pip install pynput
from pynput import keyboard
from time import sleep
import sys
mouse = Controller()
paused = True
exit_loop = False
def on_press(key):
try:
if key.char == 'A':
global paused
paused = not paused
if paused:
print('Pausing!')
else:
print('Unpausing!')
if key.char == 'Q':
global exit_loop
exit_loop = True
print("Exiting!")
sys.exit()
except AttributeError:
pass
# print('special key {0} pressed'.format( key))
def on_release(key):
# print('{0} released'.format(key))
if key == keyboard.Key.esc:
pass
#return False
listener = keyboard.Listener(
on_press=on_press,
on_release=on_release)
listener.start()
try:
interval = int(sys.argv[1])
except Exception as e:
interval = 1
print(f'Interval {interval} seconds')
print(f'Press SHIFT+A to start or pause')
print(f'Press SHIFT+Q to exit')
while not exit_loop:
if not paused:
mouse.click(Button.left, 1)
sleep(interval)