Modify

Opened 2 years ago

Closed 2 years ago

#3997 closed Bug (Completed)

Improvement of _WinAPI_RegisterShellHookWindow example

Reported by: YuTang Owned by: J-Paul Mesnage
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

Attachments (0)

Change History (1)

comment:1 by J-Paul Mesnage, 2 years ago

Milestone: 3.3.17.0
Owner: set to J-Paul Mesnage
Resolution: Completed
Status: newclosed

Added by revision [13041] in version: 3.3.17.0

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.