For example, "HSHELL_WINDOWDESTROYED" is triggered when windows are "destroyed" but it is also triggered when windows are "Hidden"! (Hehe, these so called developers really make me Lol times to times!)
Anyway, the code below demonstrates what I mentioned above:
Code: Select all
;https://autohotkey.com/board/topic/80644-how-to-hook-on-to-shell-to-receive-its-messages/#entry116488
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
loop, 3
{
gui, % a_index ":default"
gui, +HwndTempGuiId
gui, add, button, ghide, Hide gui
xPos := a_index = 1 ? a_screenwidth/2 - 320 : a_index = 2 ? a_screenwidth/2 - 100 : a_screenwidth/2 + 120
gui, show, % "x" xpos " w200 h200", % TempGuiId
}
msgbox, Press Ok to Exit!
ExitApp
hide: ;___________ hide gui __________
gui, hide
return
ShellMessage( wParam,lParam ) ;______________ Shell Message ______________
{
;if "wParam = 2", a window was hidden or destroyed (HSHELL_WINDOWDESTROYED)
if (wParam = 2)
msgbox, % "Window " lParam " / " Format("{1:#x}", lParam) " was destroyed!"
}