Jump to content

Recommended Posts

  • 1 month later...
Posted

turn off monitors:

DllCall("Dxva2.dll", "int", "SetVCPFeature", "handle", $tPhysicalMonitor.hPhysicalMonitor, _
  "byte", 0xD6, "int",0x05)  ;0x04 can too.

turn on monitors:

DllCall("Dxva2.dll", "int", "SetVCPFeature", "handle", $tPhysicalMonitor.hPhysicalMonitor, _
  "byte", 0xD6, "int", 0x01)

  • 1 year later...
Posted

Hello

I have use this script

https://www.autoitscript.com/forum/topic/206419-manage-monitors-through-ddcci-channel-using-vcp-commands/?do=findComment&comment=1487077

Please, how includes section 

#include <WinAPIGdi.au3>

in script?

My file is broken

 

#include <String.au3>
#include <Array.au3>
; #include <WinAPIGdi.au3>
#include <WinAPISysWin.au3>

; From #include <APIGdiConstants.au3>
; _WinAPI_MonitorFrom*()
Global Const $MONITOR_DEFAULTTONEAREST = 2

Local $aPos, $aData = _WinAPI_EnumDisplayMonitors()

If IsArray($aData) Then
    ReDim $aData[$aData[0][0] + 1][5]
    For $i = 1 To $aData[0][0]
        $aPos = _WinAPI_GetPosFromRect($aData[$i][1])
        For $j = 0 To 3
            $aData[$i][$j + 1] = $aPos[$j]
        Next
    Next
EndIf

_ArrayDisplay($aData, '_WinAPI_EnumDisplayMonitors')

Local $hWnd = _WinAPI_GetDesktopWindow()
ConsoleWrite($hWnd & @CRLF)
$hMonitor = _WinAPI_MonitorFromWindow($hWnd, $MONITOR_DEFAULTTONEAREST)
ConsoleWrite($hMonitor & @CRLF)

Local $aRet = DllCall("Dxva2.dll", "int", "GetNumberOfPhysicalMonitorsFromHMONITOR", "handle", $hMonitor, "int*", 0)
;_ArrayDisplay($aRet)
Local $iNumberMonitor = $aRet[2]
Const $tag_PHYSICAL_MONITOR = "handle hPhysicalMonitor; wchar strPhysicalMonitorDescription[128];"
Local $tPhysicalMonitor = DllStructCreate(_StringRepeat($tag_PHYSICAL_MONITOR, $iNumberMonitor))
$aRet = DllCall("Dxva2.dll", "int", "GetPhysicalMonitorsFromHMONITOR", "handle", $hMonitor, "int", $iNumberMonitor, "struct*", $tPhysicalMonitor)
;_ArrayDisplay($aRet)
MsgBox($MB_SYSTEMMODAL, "", $tPhysicalMonitor.strPhysicalMonitorDescription)

$aRet = DllCall("Dxva2.dll", "int", "GetCapabilitiesStringLength", "handle", $tPhysicalMonitor.hPhysicalMonitor, "int*", 0)
;_ArrayDisplay($aRet)
Local $iLength = $aRet[2] + 1
Local $tCapabilities = DllStructCreate("char sCapabilities[" & $iLength & "];")
$aRet = DllCall("Dxva2.dll", "int", "CapabilitiesRequestAndCapabilitiesReply", "handle", $tPhysicalMonitor.hPhysicalMonitor, _
  "ptr", DllStructGetPtr($tCapabilities), "int", $iLength)
;_ArrayDisplay($aRet)
ConsoleWrite($tCapabilities.sCapabilities & @CRLF)

Local Enum $MC_MOMENTARY, $MC_SET_PARAMETER ; _MC_VCP_CODE_TYPE

$aRet = DllCall("Dxva2.dll", "int", "GetVCPFeatureAndVCPFeatureReply", "handle", $tPhysicalMonitor.hPhysicalMonitor, _
  "byte", 0x10, "int*", 0, "int*", 0, "int*", 0)
;_ArrayDisplay($aRet)
ConsoleWrite($aRet[3] = $MC_MOMENTARY ? "Momentary" : ($aRet[3] = $MC_SET_PARAMETER ? "Set" : "Unknown") & @CRLF)
ConsoleWrite("Current value = " & $aRet[4] & "/" & "Maximum = " & $aRet[5] & @CRLF)

Local $iCurrent = $aRet[4]
$aRet = DllCall("Dxva2.dll", "int", "SetVCPFeature", "handle", $tPhysicalMonitor.hPhysicalMonitor, _
  "byte", 0x10, "int", 20)
Sleep(5000)
$aRet = DllCall("Dxva2.dll", "int", "SetVCPFeature", "handle", $tPhysicalMonitor.hPhysicalMonitor, _
  "byte", 0x10, "int", $iCurrent)

$aRet = DllCall("Dxva2.dll", "int", "DestroyPhysicalMonitors", "int", $iNumberMonitor, "ptr", DllStructGetPtr($tPhysicalMonitor))
;_ArrayDisplay($aRet)

; From #include <WinAPIGdi.au3>
; #FUNCTION# ====================================================================================================================
; Author.........: Yashied
; Modified.......: jpm
; ===============================================================================================================================
Func _WinAPI_EnumDisplayMonitors($hDC = 0, $tRECT = 0)
    Local $hEnumProc = DllCallbackRegister('__EnumDisplayMonitorsProc', 'bool', 'handle;handle;ptr;lparam')

    Dim $__g_vEnum[101][2] = [[0]]
    Local $aCall = DllCall('user32.dll', 'bool', 'EnumDisplayMonitors', 'handle', $hDC, 'struct*', $tRECT, _
            'ptr', DllCallbackGetPtr($hEnumProc), 'lparam', 0)
    If @error Or Not $aCall[0] Or Not $__g_vEnum[0][0] Then
        $__g_vEnum = @error + 10
    EndIf
    DllCallbackFree($hEnumProc)
    If $__g_vEnum Then Return SetError($__g_vEnum, 0, 0)

    __Inc($__g_vEnum, -1)
    Return $__g_vEnum
EndFunc   ;==>_WinAPI_EnumDisplayMonitors

; From #include <WinAPIGdi.au3>
; #FUNCTION# ====================================================================================================================
; Author.........: Yashied
; Modified.......: jpm
; ===============================================================================================================================
Func _WinAPI_MonitorFromWindow($hWnd, $iFlag = 1)
    Local $aCall = DllCall('user32.dll', 'handle', 'MonitorFromWindow', 'hwnd', $hWnd, 'dword', $iFlag)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aCall[0]
EndFunc   ;==>_WinAPI_MonitorFromWindow

; From #include <WinAPIGdi.au3>
; #FUNCTION# ====================================================================================================================
; Author.........: Yashied
; Modified.......: jpm
; ===============================================================================================================================
Func _WinAPI_GetPosFromRect($tRECT)
    Local $aResult[4]
    For $i = 0 To 3
        $aResult[$i] = DllStructGetData($tRECT, $i + 1)
        If @error Then Return SetError(@error, @extended, 0)
    Next

    For $i = 2 To 3
        $aResult[$i] -= $aResult[$i - 2]
    Next
    Return $aResult
EndFunc   ;==>_WinAPI_GetPosFromRect

 

 

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
  • Recently Browsing   0 members

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