-
Notifications
You must be signed in to change notification settings - Fork 0
/
ADC.py
35 lines (28 loc) · 834 Bytes
/
ADC.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
from pynput import keyboard
import pyautogui
def on_press(key):
try:
if key.char == 'k':
print('Start')
keyboard.Controller().press('c')
if key.char == 'l':
print('Stop')
keyboard.Controller().release('c')
if key.char == '=':
return False
except AttributeError:
print('special key {0} pressed'.format(key))
def on_release(key):
try:
if key.char == 'l':
# Stop listener
print('Stop')
keyboard.Controller.release('c')
if key.char == '=':
return False
except:
print('special key {0} pressed'.format(key))
return True
# Collect events until released
with keyboard.Listener(on_press=on_press, on_release=None) as listener:
listener.join()