Sign in to follow this  
Followers 0
azopardo

Monitor off in Windows 7

3 posts in this topic

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>

_Main()

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

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

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)
        Exit
    EndIf
EndFunc

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  
Followers 0