﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3997	Improvement of _WinAPI_RegisterShellHookWindow example	YuTang	Jpm	"Link:[https://www.autoitscript.com/autoit3/files/beta/autoit/docs/libfunctions/_WinAPI_RegisterShellHookWindow.htm]

Quote only Switch statement from the example:
{{{#!autoit
Local $sTitle = WinGetTitle($lParam)
Switch $wParam
	Case $HSHELL_REDRAW
		If IsString($sTitle) Then
			ConsoleWrite('Redrawn: ' & $sTitle & @CRLF)
		EndIf
	Case Else
		If BitAND($wParam, $HSHELL_WINDOWACTIVATED) = $HSHELL_WINDOWACTIVATED And IsString($sTitle) Then
			ConsoleWrite('Activated: ' & $sTitle & @CRLF)
			ConsoleWrite(""    $wParam: "" & $wParam & @CRLF)
		EndIf
EndSwitch
}}}

The above case-else statement seems a bit misleading.
Windows Hook Types are not for bit flag, just sequential integers. So BitAND($wParam, $HSHELL_WINDOWACTIVATED) matches not only HSHELL_WINDOWACTIVATED(4) but also HSHELL_GETMINRECT(5), HSHELL_APPCOMMAND(12), HSHELL_WINDOWREPLACED(13) and more. When I tried to run this example with SciTE, I got 'Activated' outputs twice if I clicked window minimize button. One for real activating and one for minimizing.
In addition, IsString($sTitle) returns always True because WinGetTitle function returns a window title (on success) or """" (on failure).

The below changes seems worked well for me.
{{{#!autoit
	Case $HSHELL_WINDOWACTIVATED, $HSHELL_RUDEAPPACTIVATED
}}}
"	Bug	closed	3.3.17.0	Documentation	3.3.16.1	None	Completed	_WinAPI_RegisterShellHookWindow	
