I'm currently making use of dxva2.dll in an ahk project to change monitor brightness. Currently I don't have the ability to get or set the brightness through the Monitor handle, though I have been able to create one so far. Here is what I'm working on:
; Initialize Monitor handle VarSetCapacity(ptZero, 8, 0) hMonitor := DllCall("MonitorFromPoint" , UInt, ptZero ; point on monitor , UInt, 1) ; flag to return primary monitor MsgBox, hMonitor: %hMonitor% ; Find number of Physical Monitors DllCall("dxva2\GetNumberOfPhysicalMonitorsFromHMONITOR" , UInt, hMonitor , UIntP, numMonitor) MsgBox, numMonitor: %numMonitor% ; Get Physical Monitor from handle work := DllCall("dxva2\GetPhysicalMonitorsFromHMONITOR" , UInt, hMonitor ; monitor handle , UInt, numMonitor ; monitor array size , Str, arrayMonitor) ; point to array with monitor ; Problem here, finding Physical Monitor hPhysicalMonitor := NumGet(arrayMonitor, 0, "UInt") MsgBox, work: %work% if hMonitor <> -1 { work := DllCall("dxva2\GetMonitorBrightness" , UInt, hPhysicalMonitor , UIntP, minBright , UIntP, curBright , UIntP, maxBright) MsgBox, Work: %work%`nErrorLevel: %ErrorLevel%`nLastError: %A_LastError% MsgBox, Min: %minBright%`nMax: %maxBright%`nCurrent: %curBright% }I researched it quite a bit on MSDN, and it is quite nice in comparison to what I had found here on the forum: http://www.autohotke...040.html#447040
So basically I would like to use GetMonitorBrightness to find what the current brightness is (in addition to the minimum and maximum values) and then input the brightness using SetMonitorBrightness. However, in order to do that I need to have a Physical Monitor rather than a simple Monitor Handle, as you can see I have received.
Based on the above code, I receive these messages:
hMonitor: 65537
numMonitor: 1 (only one monitor found based on the handle)
work: 1 (able to get a physical monitor array from the handle)
work: 0 (not able to use the physical monitor handle to get brightness)
errorlevel: 0 (not an error?)
lasterror: -1071241847 (don't understand this)
min: 0
max: 0
current: 0 (none of these values are found)
Here are many of the links that I have used to figure most of it out:
SetMonitorBrightness
http://msdn.microsof...2(v=VS.85).aspx
GetMonitorBrightness
http://msdn.microsof...9(v=VS.85).aspx
PHYSICAL_MONITOR
http://msdn.microsof...7(v=VS.85).aspx
GetPhysicalMonitorsFromHMONITOR
http://msdn.microsof...0(v=VS.85).aspx
GetNumberOfPhysicalMonitorsFromHMONITOR
http://msdn.microsof...8(v=VS.85).aspx
MonitorFromPoint
http://msdn.microsof...062(VS.85).aspx
Other Monitor Functions
http://msdn.microsof...4(v=VS.85).aspx
Any ideas or something I should clarify further?