-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboardmix.py
46 lines (40 loc) · 1.13 KB
/
keyboardmix.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
import os
import pythoncom, pyHook
from pyHook import HookManager
from pyHook.HookManager import HookConstants
def setVolumeActive(event):
ctrl_pressed = pyHook.GetKeyState(HookConstants.VKeyToID('VK_LCONTROL'))
alt_pressed = pyHook.GetKeyState(HookConstants.VKeyToID('VK_LMENU'))
if ctrl_pressed and alt_pressed:
return do(event)
program = ""
def chooseProgram(event):
global program
program1 = event.KeyID
program2 = event.KeyID
program3 = event.KeyID
if program1 == 97:
program = "skype.exe"
elif program2 == 98:
program = "chrome.exe"
elif program3 == 99:
program = "steam.exe"
return
def do(event):
chooseProgram(event)
setVolume(event)
return
def setVolume(event):
vol_up = event.KeyID
vol_down = event.KeyID
if vol_up == 190:
plus = 0.1
os.system("nircmd changeappvolume %s %s" %(program, plus))
elif vol_down == 188:
minus = -0.1
os.system("nircmd changeappvolume %s %s" %(program, minus))
return
hm = pyHook.HookManager()
hm.KeyDown = setVolumeActive
hm.HookKeyboard()
pythoncom.PumpMessages()