power1power1 Posted September 21, 2014 Share Posted September 21, 2014 How I can find that, in a dual monitor setup, if the second monitor is set to duplicate or extend the main monitor? Thanks. Link to comment Share on other sites More sharing options...
Luigi Posted September 21, 2014 Share Posted September 21, 2014 I have some suspicions about the solution, but nothing for sure, I'm working on it. Let's see if anyone knows and put before me. Visit my repository Link to comment Share on other sites More sharing options...
power1power1 Posted September 21, 2014 Author Share Posted September 21, 2014 Well, Windows has these options for multiple monitors: - Duplicate these displays - Extend these displays - Show desktop only on 1 - Show desktop only on 2 I need to know which option is being used. There might be a registry entry holding that information, but I couldn't find it. Link to comment Share on other sites More sharing options...
jguinch Posted September 21, 2014 Share Posted September 21, 2014 Maybe _WinAPI_EnumDisplayMonitors can help you : - In extended mode, the return array contains 2 lines (2 monitors) - In Duplicate mode, the return array contains just 1 line #include <WinAPIGdi.au3> Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") Local $colMonitors = $objWMIService.ExecQuery ("Select * from Win32_DesktopMonitor Where Availability=3", "WQL", 0x10 + 0x20) If NOT IsObj($colMonitors) Then Exit Local $iCount = 0 For $oMonitor In $colMonitors $iCount += 1 Next MsgBox(0, "", "Number of monitors : " & $iCount) $aMonitor = _WinAPI_EnumDisplayMonitors() If @error Then Exit If $aMonitor[0][0] > 1 Then MsgBox(0, "", "extended mode") Else MsgBox(0, "", "duplicate mode") EndIf sulfur 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Luigi Posted September 21, 2014 Share Posted September 21, 2014 (edited) >try this here is my contribution... expandcollapse popup;http://msdn.microsoft.com/en-us/library/aa394199(v=vs.85).aspx #include-once #include <Date.au3> #include <String.au3> #include <Array.au3> ;~ #include <object_dump.au3> Global $ERROR = "@error" Local $oo = oWIN_Monitor() dump($oo) Func oWIN_Monitor() If Not IsDeclared("ERROR") Then Local $ERROR = "@error" Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" & @ComputerName & "\root\wmi") Local $arrName = StringSplit("InstanceName,ManufacturerName,ManufacturerNameLength,ProductCodeID,SerialNumberID,WeekOfManufacture,YearOfManufacture,UserFriendlyName,UserFriendlyNameLength", ",", 2) Local $oo = ObjCreate("Scripting.Dictionary") Local $oTemp, $str Local $colItems = $objWMIService.ExecQuery("SELECT * FROM WmiMonitorID", "WQL", 0x10 + 0x20) If IsObj($colItems) Then For $objItem In $colItems $oTemp = ObjCreate("Scripting.Dictionary") $str = $objItem.InstanceName $str = $str ? $str : $ERROR $oTemp.Add("InstanceName", $str) $str = oManufacturerMonitor(StringFromASCIIArray($objItem.ManufacturerName, 0, Default, 2)) $str = $str ? $str : $ERROR $oTemp.Add("ManufacturerName", $str) $str = StringFromASCIIArray($objItem.SerialNumberID, 0, Default, 2) $str = $str ? $str : $ERROR $oTemp.Add("SerialNumberID", $str) $str = StringFromASCIIArray($objItem.UserFriendlyName, 0, Default, 2) $str = $str ? $str : $ERROR $oTemp.Add("UserFriendlyName", $str) $str = StringFromASCIIArray($objItem.ProductCodeID, 0, Default, 2) $str = $str ? $str : $ERROR $oTemp.Add("ProductCodeID", $str) $str = _DateFromWeekNumber($objItem.YearOfManufacture, $objItem.WeekOfManufacture) $str = $str ? $str : $ERROR $oTemp.Add("DateOfManufacture", $str) $oo.Add($oo.Count + 1, $oTemp) Next EndIf Return $oo EndFunc ;==>oWIN_Monitor Func _DateFromWeekNumber($iYear, $iWeekNum) ;~ http://www.autoitscript.com/forum/topic/157146-get-date-from-week-number/ Local $Date, $sFirstDate = _DateToDayOfWeek($iYear, 1, 1) If $sFirstDate < 6 Then $Date = _DateAdd("D", 2 - $sFirstDate, $iYear & "/01/01") ElseIf $sFirstDate = 6 Then $Date = _DateAdd("D", $sFirstDate - 3, $iYear & "/01/01") ElseIf $sFirstDate = 7 Then $Date = _DateAdd("D", $sFirstDate - 5, $iYear & "/01/01") EndIf Local $aDate = StringSplit($Date, "/", 2) Return _DateAdd("w", $iWeekNum - 1, $aDate[0] & "/" & $aDate[1] & "/" & $aDate[2]) EndFunc ;==>_DateFromWeekNumber Func oManufacturerMonitor($input = 0) Local $oo = ObjCreate("Scripting.Dictionary") $oo.Add("AAC", "AcerView") $oo.Add("ACR", "Acer") $oo.Add("AOC", "AOC") $oo.Add("AIC", "AG Neovo") $oo.Add("APP", "Apple Computer") $oo.Add("AST", "AST Research") $oo.Add("AUO", "Asus") $oo.Add("BNQ", "BenQ") $oo.Add("CMO", "Acer") $oo.Add("CPL", "Compal") $oo.Add("CPQ", "Compaq") $oo.Add("CPT", "Chunghwa Pciture Tubes, Ltd.") $oo.Add("CTX", "CTX") $oo.Add("DEC", "DEC") $oo.Add("DEL", "Dell") $oo.Add("DPC", "Delta") $oo.Add("DWE", "Daewoo") $oo.Add("EIZ", "EIZO") $oo.Add("ELS", "ELSA") $oo.Add("ENC", "EIZO") $oo.Add("EPI", "Envision") $oo.Add("FCM", "Funai") $oo.Add("FUJ", "Fujitsu") $oo.Add("FUS", "Fujitsu-Siemens") $oo.Add("GSM", "LG Electronics") $oo.Add("GWY", "Gateway 2000") $oo.Add("HEI", "Hyundai") $oo.Add("HIT", "Hyundai") $oo.Add("HSL", "Hansol") $oo.Add("HTC", "Hitachi/Nissei") $oo.Add("HWP", "Hewlett-Packard") $oo.Add("IBM", "IBM") $oo.Add("ICL", "Fujitsu ICL") $oo.Add("IVM", "Iiyama") $oo.Add("KDS", "Korea Data Systems") $oo.Add("LEN", "Lenovo") $oo.Add("LGD", "Asus") $oo.Add("LPL", "Fujitsu") $oo.Add("MAX", "Belinea") $oo.Add("MEI", "Panasonic") $oo.Add("MEL", "Mitsubishi Electronics") $oo.Add("MS_", "Panasonic") $oo.Add("NAN", "Nanao") $oo.Add("NEC", "NEC") $oo.Add("NOK", "Nokia Data") $oo.Add("NVD", "Fujitsu") $oo.Add("OPT", "Optoma") $oo.Add("PHL", "Philips") $oo.Add("REL", "Relisys") $oo.Add("SAN", "Samsung") $oo.Add("SAM", "Samsung") $oo.Add("SBI", "Smarttech") $oo.Add("SGI", "SGI") $oo.Add("SNY", "Sony") $oo.Add("SRC", "Shamrock") $oo.Add("SUN", "Sun Microsystems") $oo.Add("SEC", "Hewlett-Packard") $oo.Add("TAT", "Tatung") $oo.Add("TOS", "Toshiba") $oo.Add("TSB", "Toshiba") $oo.Add("VSC", "ViewSonic") $oo.Add("ZCM", "Zenith") $oo.Add("UNK", "Unknown") $oo.Add("_YV", "Fujitsu") If IsDeclared("input") And $input Then If $oo.Exists($input) Then Return $oo.Item($input) Else Return "@UNKNOW[" & $input & "]" EndIf Else Return $oo EndIf EndFunc ;==>oManufacturerMonitor Func dump($oo, $key = "", $iIdent = 0) Local $iTab = 4 Local $sKeys If IsDictionary($oo) Then $sKeys = $oo.Keys For $each In $sKeys If IsDictionary($oo.Item($each)) Or IsArray($oo.Item($each)) Then ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & $each & "{" & @LF) dump($oo.Item($each), ($key == "" ? "" : $key & ".") & $each, $iTab + $iIdent) ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & "}" & @LF) Else ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & ".") & $each & " = " & $oo.Item($each) & @LF) EndIf Next Else If IsArray($oo) Then Switch UBound($oo, 0) Case 1 For $ii = 0 To UBound($oo, 1) - 1 If IsDictionary($oo[$ii]) Or IsArray($oo[$ii]) Then dump($oo[$ii], $key & "[" & $ii & "]", $iTab + $iIdent) Else ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & "[") & $ii & "] = " & $oo[$ii] & @LF) EndIf Next Case 2 For $ii = 0 To UBound($oo, 1) - 1 For $jj = 0 To UBound($oo, 2) - 1 If IsDictionary($oo[$ii][$jj]) Or IsArray($oo[$ii][$jj]) Then dump($oo[$ii][$jj], $key & "[" & $ii & "][" & $jj & "]", $iTab + $iIdent) Else ConsoleWrite(($iIdent == 0 ? "" : (_StringRepeat(" ", $iIdent))) & ($key == "" ? "" : $key & "[") & $ii & "][" & $jj & "] = " & $oo[$ii][$jj] & @LF) EndIf Next Next EndSwitch Else EndIf EndIf EndFunc ;==>dump Func IsDictionary($oo = Null) If Not IsObj($oo) Or Not (ObjName($oo, 2) == "Scripting.Dictionary") Then Return 0 ;~ If Not (ObjName($oo, 2) == "Scripting.Dictionary") Then Return 0 Return 1 EndFunc ;==>IsDictionary Edited September 21, 2014 by Detefon Visit my repository Link to comment Share on other sites More sharing options...
power1power1 Posted September 21, 2014 Author Share Posted September 21, 2014 Thanks guys. @jguinch: When I run the code I get 0 for number of monitors. Also, I don't think the code would distinctively show the four options Windows have. @Detefon: Unfortunately, the suggested code seems too complicated for me to use. Link to comment Share on other sites More sharing options...
jaberwacky Posted September 21, 2014 Share Posted September 21, 2014 #include <WinAPIGdi.au3> #include <WindowsConstants.au3> Const $monitor_count = _WinAPI_GetSystemMetrics($SM_CMONITORS) MsgBox(0, '', "Number of monitors : " & $monitor_count) Const $aMonitor = _WinAPI_EnumDisplayMonitors() If @error Then Exit If $aMonitor[0][0] > 1 Then MsgBox(0, "", "extended mode") Else MsgBox(0, "", "duplicate mode") EndIf Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Exit Posted September 21, 2014 Share Posted September 21, 2014 Well, Windows has these options for multiple monitors: - Duplicate these displays - Extend these displays - Show desktop only on 1 - Show desktop only on 2 I need to know which option is being used. There might be a registry entry holding that information, but I couldn't find it. [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlGraphicsDriversConnectivity] App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
power1power1 Posted September 21, 2014 Author Share Posted September 21, 2014 @jaberwacky: Thanks for the number of monitors. Still, when the code message says "duplicate mode", it is actually "not-extend mode". @Exit: That registry key includes a lot of subkeys. I looked at a few of them and I didn't find any data value that show which configuration is being used. Link to comment Share on other sites More sharing options...
Exit Posted September 21, 2014 Share Posted September 21, 2014 @Exit: That registry key includes a lot of subkeys. I looked at a few of them and I didn't find any data value that show which configuration is being used.http://lmgtfy.com/?q=hkey_local_machine+system+currentcontrolset+control+graphicsdrivers+connectivity App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
power1power1 Posted September 22, 2014 Author Share Posted September 22, 2014 @Exit: We all know how to google ... @other contributors to this thread: Thank you all, I appreciate your help. Link to comment Share on other sites More sharing options...
Exit Posted September 22, 2014 Share Posted September 22, 2014 @Exit: We all know how to google ... And I googled it for you and found explanaition of the reg entries. Here is my configuration. See my comments. Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration] ; My config is a Medion as first and a Sony as second monitor [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\MED360516843009_00_07D9_F4+SNY13903491177_0D_07D4_E1^BA4B4E96467A583E200772AC5B538500] "SetId"="MED360516843009_00_07D9_F4+SNY13903491177_0D_07D4_E1" "Timestamp"=hex(b):00,f7,bf,f9,fc,d5,cf,01 ; Key 00 is monitor number 1 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\MED360516843009_00_07D9_F4+SNY13903491177_0D_07D4_E1^BA4B4E96467A583E200772AC5B538500\00] ; screensize in hex "PrimSurfSize.cx"=dword:00000780 "PrimSurfSize.cy"=dword:00000438 "Stride"=dword:00001e00 "PixelFormat"=dword:00000015 "ColorBasis"=dword:00000002 ; x or y not 0 means "This is the desktop expansion monitor "Position.cx"=dword:00000500 "Position.cy"=dword:00000000 ; Key 01 is monitor number 2 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\MED360516843009_00_07D9_F4+SNY13903491177_0D_07D4_E1^BA4B4E96467A583E200772AC5B538500\01] ; screensize in hex "PrimSurfSize.cx"=dword:00000500 "PrimSurfSize.cy"=dword:00000400 "Stride"=dword:00001400 "PixelFormat"=dword:00000015 "ColorBasis"=dword:00000002 ; x/y = 0 means "This is the desktop monitor with START button and SYSTEM TRAY" "Position.cx"=dword:00000000 "Position.cy"=dword:00000000 Enough spoonfeeding ? App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
power1power1 Posted September 22, 2014 Author Share Posted September 22, 2014 @Exit: Thanks, but, no thanks. Your response does not address the question: How to find, in a dual display setup, which of these options: 1st display only, 2nd display only, extend desktop or duplicate desktop is being used. By the way, recent Windows versions, have system tray on both 1st and 2nd displays. Link to comment Share on other sites More sharing options...
j0kky Posted September 22, 2014 Share Posted September 22, 2014 pCurrentTopologyId parameter of QueryDisplayConfig function points to a DISPLAYCONFIG_TOPOLOGY_ID enumeration, it tells you if the monitor is extend or duplicate (clone). It is available only in windows 7 (and maybe in higher OS) Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
power1power1 Posted September 22, 2014 Author Share Posted September 22, 2014 @j0kky: Thank you. Great hint. I need to spend some time on this to see if I can figure out how to use it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now