Jump to content

Search the Community

Showing results for tags 'display on off'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 1 result

  1. I needed a function that checks whether the display/monitor is on or off and because I didn't find one I wrote this: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DisplayState ; Description ...: Checks if a display is on or off. ; Syntax ........: _DisplayState() ; Parameters ....: None ; Return values..: Success - 1 = screen is on ; 0 = screen is off ; Failure - -1 and sets the @error flag to non-zero. ; Author ........: syk3s ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ RegisterPowerSettingNotification ; Example .......: No ; =============================================================================================================================== Func _DisplayState($hWndGUI = 0, $MsgID = 0, $WParam = 0, $LParam = 0) Local Const $_GUID_MONITOR_POWER_ON = '{02731015-4510-4526-99E6-E5A17EBD1AEA}' Local Const $_tagGUID = "ulong Data1;ushort Data2;ushort Data3;byte Data4[8]" If IsDeclared($_iDisplayState) = 0 Then Global $_iDisplayState = -1 If $hWndGUI = 0 And $MsgID = 0 Then Global $_iDisplayState = -1 Local Const $_WM_POWERBROADCAST = 0x0218 Local $hTemp, $tGUID, $Ret Local $hTemp = GUICreate("Display state") If IsHWnd($hTemp) = 0 Then Return SetError(1, 0, -1) EndIf If GUIRegisterMsg($_WM_POWERBROADCAST, "_DisplayState") = 0 Then Return SetError(2, 0, -1) EndIf ;register for a display state broadcast $tGUID = DllStructCreate($_tagGUID) If @error Then Return SetError(3, 0, -1) EndIf $Ret = DllCall('ole32.dll', 'uint', 'CLSIDFromString', 'wstr', $_GUID_MONITOR_POWER_ON, 'ptr', DllStructGetPtr($tGUID)) If (@error) Or ($Ret[0]) Then Return SetError(4, 0, -1) EndIf $Ret = DllCall('user32.dll', 'ptr', 'RegisterPowerSettingNotification', 'hwnd', $hTemp, 'ptr', DllStructGetPtr($tGUID), 'dword', 0) ;register for the event If (@error) Or (Not $Ret[0]) Then Return SetError(5, 0, -1) EndIf DllCall('user32.dll', 'int', 'UnregisterPowerSettingNotification', 'ptr', $Ret[0]) ;unregister GUIDelete($hTemp) If $_iDisplayState <> 0 And $_iDisplayState <> 1 Then Return SetError(6, 0, -1) Else Return $_iDisplayState EndIf Else Local $stPOWERBROADCAST_SETTING = DllStructCreate($_tagGUID & ";DWORD;byte[1]", $LParam) Local $aResult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", DllStructGetPtr($stPOWERBROADCAST_SETTING), "wstr", "", "int", 40) ;get string GUID back If $aResult[2] = $_GUID_MONITOR_POWER_ON Then $_iDisplayState = DllStructGetData($stPOWERBROADCAST_SETTING, 6, 1) EndIf EndFunc ;==>_DisplayState If you have some ideas for improvement, please post them below. Note: works only with Vista+ and maybe doesn't work with Windows 8, needs testing
×
×
  • Create New...