1
+ #! python3
2
+ import pyautogui , sys , time , serial
3
+
4
+ port = 'COM6' #Windows COMX | Linux /dev/ttyUSBX or /dev/ttyACMX
5
+ baud = 9600
6
+
7
+ NanoSerial = serial .Serial (port , baud )
8
+ time .sleep (1 )
9
+
10
+ print ("MacroKeyPad:" , port , baud )
11
+
12
+ while 1 :
13
+ data = str (NanoSerial .readline ())[2 ]
14
+ if data == '7' :
15
+ pyautogui .press ('prevtrack' ) #Previous track
16
+ elif data == '8' :
17
+ pyautogui .press ('playpause' ) #Play/Pause
18
+ elif data == '9' :
19
+ pyautogui .press ('nexttrack' ) #Next track
20
+ elif data == '4' :
21
+ pyautogui .press ('volumedown' ) #Turn volume down
22
+ elif data == '5' :
23
+ pyautogui .press ('volumemute' ) #Turn volume on/off
24
+ elif data == '6' :
25
+ pyautogui .press ('volumeup' ) #Turn volume up
26
+ elif data == '1' :
27
+ pyautogui .hotkey ('ctrl' , 'alt' , 'c' ) #Chatting
28
+ elif data == '2' :
29
+ pyautogui .hotkey ('ctrl' , 'alt' , 'd' ) #Gaming
30
+ elif data == '3' :
31
+ pyautogui .hotkey ('ctrl' , 'alt' , 'f' ) #Waiting
32
+ elif data == '*' :
33
+ pyautogui .hotkey ('ctrl' , 'alt' ,'a' ) #Start/Stop streaming OBS
34
+ elif data == '0' :
35
+ pyautogui .hotkey ('ctrl' , 'alt' ,'b' ) #Start/Stop recording OBS
36
+ elif data == '#' :
37
+ pyautogui .hotkey ('ctrl' , 'alt' ,'e' ) #Transition OBS
38
+ elif data == 'A' :
39
+ pyautogui .hotkey ('ctrl' , 'alt' ,'g' ) #Mute/Unmute desktop
40
+ elif data == 'B' :
41
+ pyautogui .hotkey ('ctrl' , 'alt' , 'h' ) #Mute/Unmute headset
42
+ elif data == 'C' :
43
+ pyautogui .hotkey ('ctrl' , 'alt' ,'i' ) #Mute/Unmute mic
44
+ elif data == 'D' :
45
+ pyautogui .hotkey ('ctrl' , 'alt' ,'del' )
0 commit comments