Function Reference


_WinAPI_RegisterWindowMessage

Defines a new window message that is guaranteed to be unique throughout the system

#include <WinAPISysWin.au3>
_WinAPI_RegisterWindowMessage ( $sMessage )

Parameters

$sMessage String that specifies the message to be registered

Return Value

Success: A message identifier in the range 0xC000 through 0xFFFF
Failure: 0, call _WinAPI_GetLastError() to get extended error information

Remarks

The RegisterWindowMessage function is used to register messages for communicating between two cooperating
applications. If two different applications register the same message string, the applications return the same
message value. The message remains registered until the session ends.

See Also

Search RegisterWindowMessage in MSDN Library.

Example

#include <APISysConstants.au3>
#include <WinAPISysWin.au3>

Opt('TrayAutoPause', 0)

OnAutoItExitRegister(OnAutoItExit)

Global $g_hForm = GUICreate('')
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), WM_SHELLHOOK)
_WinAPI_RegisterShellHookWindow($g_hForm)

While 1
        Sleep(1000)
WEnd

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
        #forceref $iMsg

        Switch $hWnd
                Case $g_hForm
                        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)
                                        EndIf
                        EndSwitch
        EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func OnAutoItExit()
        _WinAPI_DeregisterShellHookWindow($g_hForm)
EndFunc   ;==>OnAutoItExit