Function Reference


_SendMessage

Wrapper for commonly used DLL Call

#include <SendMessage.au3>
_SendMessage ( $hWnd, $iMsg [, $wParam = 0 [, $lParam = 0 [, $iReturn = 0 [, $wParamType = "wparam" [, $lParamType = "lparam" [, $sReturnType = "lresult"]]]]]] )

Parameters

$hWnd Window/control handle
$iMsg Message to send to control (number)
$wParam [optional] Specifies additional message-specific information
$lParam [optional] Specifies additional message-specific information
$iReturn [optional] What to return:
    0 - Return value from DLL call
    1 - $ihWnd
    2 - $iMsg
    3 - $wParam
    4 - $lParam
    <0 or > 4 - array same as DllCall()
$wParamType [optional] See DllCall in Related
$lParamType [optional] See DllCall in Related
$sReturnType [optional] See DllCall in Related

Return Value

Success: the user selected value from the DllCall() result.
Failure: sets the @error flag to non-zero.

Remarks

When a message is blocked by UIPI the last error, retrieved with _WinAPI_GetLastError(), is set to 5 (access denied).

Related

DllCall(), _SendMessageA, _WinAPI_GetLastError

Example

#include <MsgBoxConstants.au3>
#include <SendMessage.au3>

Example()

Func Example()
        Local Const $iOff = 2, $iOn = -1

        Opt("WinTitleMatchMode", 4)
        Local $hWnd = WinGetHandle('classname=Progman')
        _ToggleMonitor($hWnd, $iOff)
        Sleep(3000)
        _ToggleMonitor($hWnd, $iOn)
EndFunc   ;==>Example

Func _ToggleMonitor($hWnd, $iOnOff)
        Local Const $WM_SYSCOMMAND = 274
        Local Const $SC_MONITORPOWER = 61808
        _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_MONITORPOWER, $iOnOff)
        If @error Then
                MsgBox($MB_SYSTEMMODAL, "_ToggleMonitor", "_SendMessage Error: " & @error)
                Exit
        EndIf
EndFunc   ;==>_ToggleMonitor