-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (25 loc) · 766 Bytes
/
main.py
File metadata and controls
35 lines (25 loc) · 766 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
35
from Sound.sound import Sound
from pynput import keyboard
global pressed
global key_to_mute
pressed = False
"""
Only thing you need to edit is the key_to_mute variable.
Uncomment the block below to view the available keys.
"""
key_to_mute = keyboard.Key.ctrl_r
# for key in keyboard.Key:
# print('keyboard.' + str(key))
#
# exit()
def on_press(key):
if key == globals()['key_to_mute'] and not globals()['pressed']:
globals()['pressed'] = True
Sound.mute()
def on_release(key):
if key == globals()['key_to_mute'] and globals()['pressed']:
globals()['pressed'] = False
Sound.mute()
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
print(Sound.current_volume())
listener.join()