Modify

#3997 closed Bug (Completed)

Improvement of _WinAPI_RegisterShellHookWindow example

Reported by: YuTang Owned by: Jpm
Milestone: 3.3.17.0 Component: Documentation
Version: 3.3.16.1 Severity: None
Keywords: _WinAPI_RegisterShellHookWindow Cc:

Description

Link:https://www.autoitscript.com/autoit3/files/beta/autoit/docs/libfunctions/_WinAPI_RegisterShellHookWindow.htm

Quote only Switch statement from the example:

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.

        Case $HSHELL_WINDOWACTIVATED, $HSHELL_RUDEAPPACTIVATED

Change History (1)

comment:1 Changed 16 months ago by Jpm

  • Milestone set to 3.3.17.0
  • Owner set to Jpm
  • Resolution set to Completed
  • Status changed from new to closed

Added by revision [13041] in version: 3.3.17.0

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.