Code: Select all
Gui +LastFound
hWnd:=WinExist()
DllCall("RegisterShellHookWindow", UInt,hWnd)
MsgNum:=DllCall("RegisterWindowMessage", Str,"SHELLHOOK")
OnMessage(MsgNum, "SwitchMessage")
HSHELL_WINDOWCREATED:=1
Return
msgbox, TEST
Code: Select all
Gui +LastFound
hWnd:=WinExist()
DllCall("RegisterShellHookWindow", UInt,hWnd)
MsgNum:=DllCall("RegisterWindowMessage", Str,"SHELLHOOK")
OnMessage(MsgNum, "SwitchMessage")
HSHELL_WINDOWCREATED:=1
Return
msgbox, TEST
gosh. you're right. But I still got problem:
Code: Select all
Gui +LastFound
hWnd:=WinExist()
DllCall("RegisterShellHookWindow", UInt,hWnd)
MsgNum:=DllCall("RegisterWindowMessage", Str,"SHELLHOOK")
OnMessage(MsgNum, "SwitchMessage")
HSHELL_WINDOWCREATED:=1
SwitchMessage( wParam,lParam )
{
If ( wParam != 1 )
{
If WinActive("ahk_exe explorer.exe")
{
MsgBox, explorer detected!
}
}
}
ReloadTimer := % 1000*5
;reload timer
Gosub,AutoReloadInit
AutoReloadInit:
SetTimer, SelfReload, % ReloadTimer
return
SelfReload:
MsgBox, TEST
reload
return
Code: Select all
ReloadTimer := % 1000*5
;reload timer
Gosub,AutoReloadInit
AutoReloadInit:
SetTimer, SelfReload, % ReloadTimer
return
SelfReload:
MsgBox, TEST
reload
return
Gui +LastFound
hWnd:=WinExist()
DllCall("RegisterShellHookWindow", UInt,hWnd)
MsgNum:=DllCall("RegisterWindowMessage", Str,"SHELLHOOK")
OnMessage(MsgNum, "SwitchMessage")
HSHELL_WINDOWCREATED:=1
SwitchMessage( wParam,lParam )
{
If ( wParam != 1 )
{
If WinActive("ahk_exe explorer.exe")
{
MsgBox, explorer detected!
}
}
}
Code: Select all
; [...]
return ; this return makes the following code unreachable
Gui +LastFound ; here is no label to jump to - this code gets never executed
hWnd:=WinExist()
DllCall("RegisterShellHookWindow", UInt,hWnd)
MsgNum:=DllCall("RegisterWindowMessage", Str,"SHELLHOOK")
OnMessage(MsgNum, "SwitchMessage")
HSHELL_WINDOWCREATED:=1
;[...]