-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindow Events.ahk
37 lines (31 loc) · 948 Bytes
/
Window Events.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
#SingleInstance Force
#NoTrayIcon
Persistent
DetectHiddenWindows(true)
#Include "Common.ahk"
trayed := []
toTray(win) {
if(!includes(trayed, win)) {
Run('"' A_AhkPath '" "Windows\ToTray.ahk" "' win '" "wait"')
trayed.push(win)
SetTimer(() => (WinWaitClose(win), trayed.RemoveAt(includes(trayed, win))), -1)
}
}
act(id, setting, action:= () => true) {
setting:= GetSetting(setting, true)
try
if(includes(setting, WinGetProcessName("ahk_id " id)) ||
includes(setting, id,, true))
return action()
}
recipient(message, id, *) {
if(message == 1) {
act(id, "Transparent Windows", () => WinSetTransparent(Round(255 * 0.85), "ahk_id " id))
act(id, "Close On Open", () => WinClose("ahk_id " id))
act(id, "Open To Tray", () => toTray("ahk_id " id))
}
}
detector := Gui()
DllCall("RegisterShellHookWindow", "UInt",detector.Hwnd)
messenger := DllCall("RegisterWindowMessage", "Str","SHELLHOOK")
OnMessage(messenger, recipient)