Share this page 

Turn on/off the monitorTag(s): WinAPI/Registry


[local function declaration]
FUNCTION long SendMessageA &
    (long hwnd,  long  msg, long wparam, long lparam) &
    LIBRARY "USER32.DLL"

[powerscript]
CONSTANT long SC_MONITORPOWER = 61808
CONSTANT long WM_SYSCOMMAND = 274
CONSTANT long MONITOR_ON = -1
CONSTANT long MONITOR_OFF = 2
// CONSTANT long MONITOR_STANDBY = 1

long hWnd
hWnd = handle(parent) // from a button, retrieve the window handle

SendMessageA(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF)
Sleep(2)
SendMessageA(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON)