Jump to content

Monitor Configuration UDF


jaberwacky
 Share

Recommended Posts

I found these functions on MSDN which control various aspects of monitors such as brightness, contrast, color temperature, etc.  This works on my monitors on Windows7 x64.  Your mileage may vary.  Doesn't work on anything lower than Windows Vista.  Not all monitors are supported.

Requires the latest AutoIt3 beta.

[10-17-2013] -- The VCPs described in the MCCS standard are now wrapped up into Monitor Configuration Wrapper.au3.  BE CAREFUL WITH THESE!  I made this UDF without any real understanding of why.  I do not foresee myself using these, but I put them out here in case someone else does.  These functions are all untested.  I leave it up to you to decide if the functions that you want to use have been implemented correctly.  If you bork your monitor, then go out and buy yourself something really nice.

Here are the required au3 files: Monitor Configuration.zip
previous: 52

The list of files in the UDF:

    Monitor Configuration Wrapper.au3 -- This wraps up the MCCS standard into a UDF.  Deprecates Low Level.au3.  Beware.

    Example High Level.au3 -- Run this example for a simple monitor configuration dashboard.

    Monitor Configuration High Level.au3   

    Monitor Configuration Low Level.au3 -- Deprecated.

    Monitor Configuration Constants.au3

    Monitor Configuration.au3 -- Internal, do not use.

What's that?  You want to turn off your monitor programmatically?

#include "Monitor Configuration Wrapper.au3"

Global Const $physical_monitor = GetPhysicalMonitorsFromHMonitor(_WinAPI_EnumDisplayMonitors()[1][0])

PowerMode($physical_monitor, $POWER_OFF)
Edited by jaberwacky
wrong info
Link to comment
Share on other sites

  • 1 month later...

Read the first post again, it requires the beta version of AutoIt..

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 1 year later...

Well, there are several problems with this UDF.  Not surprising considering that I just did this to be able put out a UDF where I did not see one before, without a 100% understanding of monitor technology.  I did download and follow the standard though.  Hopefully someone can build on this and make it work correct. 

You may be able to do what you ask.  I don't know if the function I coded is coded proper or not.  Have you gave it a try yet?  Also, which function is it that provides this serial? Edit: the function (I believe) is: EDIDOperation.

Edit Again: In case you want to try the original function and this new version:

Func EDIDOperation(Const $physical_monitor, Const $block_number)
    Local Const $return = SetVCPFeature($physical_monitor, 0x78, $block_number)

    Return (@error ? SetError(1, @extended, False) : $return)
EndFunc
Edited by jaberwacky
Link to comment
Share on other sites

Hi jaberwacky,

At the beginning of my research I saw your UDF, I didnt work so 2-day journey of research followed.  I was on WMI  > "WmiMonitorID"  which can read the serial but cannot associate it with a monitor number (this was hard to swallow)

Now I took a  deeper look into your UDF again. It the capabilities are amazing...but:

GetNumberOfPhysicalMonitorsFromHMonitor()  fails. Argh...it returns 0 for all handles. And throws no errors.

I thought it might be a problem in your implementation so I tried implementations in other programming languages but all the same. ( I am on Win8.1x64 autoit v3.3.10.0 )

It might have something to do with my Monitor Configuration (DisplayPort > Adapters > Monitor)

 

But on the other hand I found a c# project which can successfully save my monitor configuration using the dxva2: http://sourceforge.net/projects/monitorswitcher/

 

Do you have any idea what we can debug here to find the root of the problem?

 

best regards

Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Link to comment
Share on other sites

Could have something to do with OP's first post.

 

Edit: I found some issues with this UDF.  Please do not use it.

this might be the issue you are talking about? :)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

@ Community

Can some of the community test the following code quickly and post the results? I would like to know if it is a specific problem to my computer configuration

#include <WinAPIGdi.au3>
$physical_monitor = DllStructCreate("handle physicalMonitor;wchar physicalMonitorDescription[128]")
DllCall( "Dxva2.dll" , "bool",  "GetPhysicalMonitorsFromHMONITOR",  "handle",  _WinAPI_EnumDisplayMonitors()[1][0],  "dword",   1,  "ptr", DllStructGetPtr( $physical_monitor ) )
ConsoleWrite(  @OSVersion   &  @OSArch  & @LF & DllStructGetData($physical_monitor, "physicalMonitor")   &  @LF  & DllStructGetData($physical_monitor, "physicalMonitorDescription")    & @LF  )

@ jaberwacky

I used the "EDIDOperation". ...ok It reads the EDID-Block  ( 12-15 = monitor serial number > http://en.wikipedia.org/wiki/Extended_display_identification_data )

But it only tells me that it succeded...now where is the data  o:) ? 

I know you are not an monitor expert...but honestly...who else should know if not you :)

If we solve the problem we can also answer this thread: '?do=embed' frameborder='0' data-embedContent>>

 

btw i recommend linking this in the op: http://msdn.microsoft.com/en-us/library/windows/desktop/dd692964(v=vs.85).aspx  ( as I had my problems figuring out which api you are using firstly )

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Link to comment
Share on other sites

GetNumberOfPhysicalMonitorsFromHMonitor()  fails. Argh...it returns 0 for all handles. And throws no errors.

I thought it might be a problem in your implementation so I tried implementations in other programming languages but all the same. ( I am on Win8.1x64 autoit v3.3.10.0 )

Did you run this example in the OP?

#include "Monitor Configuration Wrapper.au3" 

Global Const $physical_monitor = GetPhysicalMonitorsFromHMonitor(_WinAPI_EnumDisplayMonitors()[1][0]) 

PowerMode($physical_monitor, $POWER_OFF)

It works for me.

Edited by jaberwacky
Link to comment
Share on other sites

Could have something to do with OP's first post.

this might be the issue you are talking about? :)

Actually, you're spot on.  This is the exact reason that I put that disclaimer up there.  But I figure that nothing catastrophic could result so I left it available.

Link to comment
Share on other sites

I don't really know.  Some forum posts seem to indicate that it can't be read this easily.  But it seems that Windows can read it because it stores the EDID in the registry.  So, I tried:

Func EDIDOperation(Const $physical_monitor)
  Local Const $return = GetVCPFeatureAndVCPFeatureReply($physical_monitor, 0x78)
 
  Return (@error ? SetError(1, @extended, False) : $return)
EndFunc
 
ConsoleWrite(EDIDOperation($physical_monitor)[0] & @CRLF)

To no avail.

If the standard says that 78h is the VCP then I can't just say 0x78 can I?   I have to convert it from hex to decimal, so 120?  I tried it but I don't know if this is the reason it won't work or some other reason.  Answered my own question.  I follow the 0x convention in the example in the OP and that works fine so I assume I can just turn the h into a 0x.

Edited by jaberwacky
Link to comment
Share on other sites

1. OP example didnt work because GetPhysicalMonitorsFromHMonitor didnt work. (I thought but I tried with manual monitorNumbers "1", "2"...which is what GetPhysicalMonitorsFromHMonitor returns???)

 

2. 78h means 78hex means 0x78

 

3. You changed EDIDOperation to from  GetVCPFeature   in to GetVCPFeatureAndVCPFeatureReply which is better but for me returns [ 0 0 0 ] for any blocks and any monitorNumbers (and for you???)

    *found a small mistake in your   GetVCPFeatureAndVCPFeatureReply  > it returns [ $VCPCodeType    $CurrentValue    $CurrentValue ]   instead of   [  $VCPCodeType     $CurrentValue     $MaximumValue ]

 

4. Its no problem to read the EDID from registry but they are not in PhysicalMonitorNumber-order so I cannot correlate them to my monitors, which I intend

 

5. I tried it in virtual machine, doesnt work either. I think I will give up for the moment, which is very hard after so much time spend :(

Edited by Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Link to comment
Share on other sites

Run this code please:

#include "Monitor Configuration Wrapper.au3"

Const $h_monitor = _WinAPI_EnumDisplayMonitors()[1][0]
 
Const $_physical_monitor = GetPhysicalMonitorsFromHMonitor($h_monitor)

ConsoleWrite(GetMonitorCapabilities($_physical_monitor) & @CRLF)

 

If it returns 0 then your monitor doesn't support these functions.

Link to comment
Share on other sites

Hi,

It returns 0. But that might be because of  GetPhysicalMonitorsFromHMonitor returns 0 before. Also the c#-Project I meantioned (http://sourceforge.net/projects/monitorswitcher/) does use the same API with success.

And I have several ( 7 :) ) very modern LED-Monitors which must support this standards.

However, Monitorconfiguration is a very complex topic, and it might have somethink to do with my computer config.

Anyway I dont die without these functions, and for everyone else this is great work done here and I could highly recommend this powerful udf.

I just fear, your "I code the 0.9-version and anyone else will pick up and maintain it" is a bit illusive, and I would encourage you to take the main responsibility for the udf. But thats just my opinion (in bad english  :))

 

thank you & best regards

Bluesmaster 

My UDF: [topic='156155']_shellExecuteHidden[/topic]

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...