-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmuteDesktop.ahk
81 lines (72 loc) · 1.87 KB
/
muteDesktop.ahk
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
VD_init()
^Numpad1:: ;ctrl+Numpad1
^Numpad2:: ;ctrl+Numpad2
^Numpad3:: ;ctrl+Numpad3
whichDesktop:=SubStr(A_ThisHotkey, 0) ;get last character from numpad{N}
muteDesktop(whichDesktop)
return
#Numpad1:: ;win+Numpad1
#Numpad2:: ;win+Numpad2
#Numpad3:: ;win+Numpad3
whichDesktop:=SubStr(A_ThisHotkey, 0) ;get last character from numpad{N}
UnmuteDesktop(whichDesktop)
return
#!m:: ;win+alt+m
currentDesktop:=VD_getCurrentVirtualDesktop()
MuteAllButThisDesktop(currentDesktop)
return
#!u:: ;win+alt+u
UnmuteAll()
return
MuteAllButThisDesktop(desktopNumber)
{
vd_Count := VD_getCount()
loop %vd_Count% {
if (A_Index!=desktopNumber) {
MuteDesktop(A_Index)
}
}
}
UnmuteAll()
{
vd_Count := VD_getCount()
loop %vd_Count% {
UnmuteDesktop(A_Index)
}
}
MuteDesktop(desktopNumber)
{
muteOrUnmuteDesktop(desktopNumber, hasVolume:=false)
}
UnmuteDesktop(desktopNumber)
{
muteOrUnmuteDesktop(desktopNumber, hasVolume:=true)
}
muteOrUnmuteDesktop(desktopNumber, hasVolume:=true)
{
DetectHiddenWindows, on
WinGet windows, List
Loop %windows%
{
id := windows%A_Index%
IfEqual, False, % VD_isValidWindow(id), continue
desktopOfWindow:=VD_getDesktopOfWindow("ahk_id " id)
if (desktopOfWindow=desktopNumber)
{
DetectHiddenWindows, on
WinGet, windowPID, PID, % "ahk_id " id
if (windowPID) {
toRun=nircmd.exe setappvolume /%windowPID% %hasVolume%
; p(toRun)
Run, %toRun%
}
}
}
DetectHiddenWindows, off
}
return
f3::Exitapp