Skip to content

Instantly share code, notes, and snippets.

@jploudre
Created December 6, 2015 15:57
Show Gist options
  • Select an option

  • Save jploudre/1c90df432859f3cfa913 to your computer and use it in GitHub Desktop.

Select an option

Save jploudre/1c90df432859f3cfa913 to your computer and use it in GitHub Desktop.
Shell hook for window open
#Persistent
SetBatchLines, -1
Process, Priority,, High
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return
ShellMessage( wParam,lParam )
{
If ( wParam = 1 ) ; HSHELL_WINDOWCREATED := 1
{
WinGetTitle, Title, ahk_id %lParam%
If ( Title = "WorkRest" )
WinClose, ahk_id %lParam% ; close it immideately
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment