Jump to content

Screen off/on


Recommended Posts

Opt("WinTitleMatchMode', 4)

$WM_SYSCommand = 274
$SC_MonitorPower = 61808
$Power_On = -1
$Power_Off = 2
$X = 1

$HWND = WinGetHandle('classname=Progman')

While 1
   If $X = 1 Then
      $X = 0
      DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", _
      $SC_MonitorPower, "int", $Power_Off)
   Else
      $X = 1
      DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", _
      $SC_MonitorPower, "int", $Power_On)
   EndIf
   Sleep(10000)
WEnd

I wrote a tidyer version of the above somewhere on the forums but can't seem to find it. The above should work.

Edit: Found it...

http://www.autoitscript.com/forum/index.ph...topic=11122&hl=

Edited by Burrup

qq

Link to comment
Share on other sites

made it into a function for you lazy nubs :)

Func _MonitorPower($i_Power)
    
    If $i_Power <> 0 AND $i_Power <> 1 Then
        SetError(1)
        return 0
    EndIf
    
    Local $ai_PowerState[2] = [2, -1]
    
    Local $i_WTMM = Opt("WinTitleMatchMode", 4)
    
    DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle('classname=Progman'), "int", 274, "int", 61808, "int", $ai_PowerState[$i_Power])
    
    Opt("WinTitleMatchMode", $i_WTMM)
    
    return 1
    
EndFunc


;ConsoleWrite(_MonitorPower(0) & @LF)
;Sleep(10000)
;ConsoleWrite(_MonitorPower(1) & @LF)

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...