Jump to content



Photo

Function: monitor_resolutions


  • Please log in to reply
1 reply to this topic

#1 jftuga

jftuga

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 315 posts

Posted 12 September 2006 - 08:41 PM

I also attached it (see below the code) so that you can download it.

-John

PS: Made a small update to fix a problems with laptops.


AutoIt         
; function monitor_resolutions() ; -John Taylor ; Sept-9-2006 ; ; returns an array of monitors with their corresponding resolutions ; array[0][0] contains the number of monitors ; array[1][0] is the width of the 1st monitor ; array[1][1] is the height of the 1st monitor Opt("MustDeclareVars", 1) Func monitor_resolutions()     local $wmi_svc, $slots, $monitor     local $h, $v     local $i     local $results[16][2]     local $debug = 0     $wmi_svc = ObjGet("winmgmts:\\.\root\CIMV2")     if "" == $wmi_svc then         if 1 == $debug then MsgBox(0,"WMI Error", "Can connect to WMI service")         return -1     endif     $slots = $wmi_svc.ExecQuery("SELECT CurrentHorizontalResolution,CurrentVerticalResolution FROM Win32_VideoController", "WQL", (0x10 + 0x20) )     if Not IsObj( $slots ) then         if 1 == $debug then MsgBox(0, "WMI Error", "No WMI objects found")         return -2     endif     ; count the number of monitors and     ; iterate through each monitor and populate the $results array     $i = 0     for $monitor in $slots         $h = int($monitor.CurrentHorizontalResolution)         $v = int($monitor.CurrentVerticalResolution)         if $h <= 1 or $v <= 1 then ContinueLoop         $i += 1         if 1 = $debug then MsgBox(0, "Monitor " & $i, "Resolution : " & $h & "x" & $v)         $results[$i][0] = $h         $results[$i][1] = $v     next     $results[0][0] = $i     return $results EndFunc ; testing Dim $mon = monitor_resolutions() Dim $j for $j = 1 to $mon[0][0]     MsgBox(0, "Monitor " & $j, $mon[$j][0] & "x" & $mon[$j][1]) next

Attached Files


Edited by jftuga, 13 September 2006 - 12:23 PM.








#2 lod3n

lod3n

    Another day, another mind-boggling adventure!

  • Active Members
  • PipPipPipPipPipPip
  • 874 posts

Posted 15 September 2006 - 12:08 AM

Great! Good work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users