-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhide-by-window.ahk
76 lines (64 loc) · 1.82 KB
/
hide-by-window.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
;false = only hide volume OSD in windows matching exeNames, true = only show volume OSD in those windows
hideByDefault := false
;list of window process exes to match against
exeNames := ["phpstorm64.exe"]
#include %A_ScriptDir%\VolumeOsd.ahk
;create a shell hook to track whenever the active window changes
Gui +LastFound
DllCall("RegisterShellHookWindow", UInt, WinExist())
MsgNum := DllCall("RegisterWindowMessage", Str, "SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
;immediately show or hide the volume OSD based on the user's choice
if(hideByDefault)
{
VolumeOsd.Hide()
} else {
VolumeOsd.Show()
}
ShellMessage(wParam, lParam)
{
global hideByDefault
global exeNames
;check for HSHELL_WINDOWACTIVATED (4) or HSHELL_RUDEAPPACTIVATED (32772, used when there is a full screen window)
if(wParam = 4 or wParam = 32772)
{
;get the executable filename of the active window
WinGet, name, ProcessName, A
;get the executable path and filename of the active window
;WinGet, path, ProcessPath, A
;get the title of the active window
;WinGetTitle, title, ahk_id %lParam%
;check whether or not the active Window's executable filename is in the match list
if(InArray(exeNames, name))
{
if(hideByDefault)
{
VolumeOsd.Show()
} else {
VolumeOsd.Hide()
}
} else {
if(hideByDefault)
{
VolumeOsd.Hide()
} else {
VolumeOsd.Show()
}
}
}
}
InArray(haystack, needle)
{
if(!IsObject(haystack) || haystack.Length() = 0)
{
return false
}
for index, value in haystack
{
if (value = needle)
{
return true
}
}
return false
}