Jump to content
Sign in to follow this  

Monitor off in Windows 7

Recommended Posts


Hi, I´m trying to use this code in Windows 7 but is not working.

Does anybody know if WM_SYSCOMMAND and SC_MONITORPOWER are still supported in Win7?

In case is not, what are the replacemente for this functions?

thanks in advance

#include <SendMessage.au3>


Func _Main()
    Local Const $Off = 2, $On = -1

    Opt("WinTitleMatchMode", 4)
    $hwnd = WinGetHandle('classname=Progman')
    _ToggleMonitor($hWnd, $Off)
    Sleep ( 3000 )
    _ToggleMonitor($hWnd, $On)

Func _ToggleMonitor($hwnd, $OnOff)
    Local Const $WM_SYSCOMMAND = 274
    Local Const $SC_MONITORPOWER = 61808
    _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_MONITORPOWER, $OnOff)
    If @error Then
        MsgBox(0,"_ToggleMonitor", "_SendMessage Error: " & @error)

Share this post

Link to post
Share on other sites

Works for me. Maybe something UAC related? Are you testing with an admin account?

Thanks KaFu, I will try again

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.