Jump to content

Determine screen resolution of multiple monitors


ahha
 Share

Recommended Posts

Okay I've scanned the boards (may have missed it) and looked as best I can at the dll's for a clue. Here's a program that is little more than @DesktopWidth and @DesktopHeight making some DLL calls for the virtual screen but I can't seem to find how to find the screen resolution for a 2nd or 3rd monitor. Any hints greatly appreciated.

; use this to debug in console window <--- LOOK
;#AutoIt3Wrapper_run_debug_mode=Y

;author: ahha
;filename: determine screen sizes v1b.au3

;http://msdn.microsoft.com/en-us/library/ms724385%28VS.85%29.aspx

$VirtX = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 78)    ;SM_CXVIRTUALSCREEN 78
;The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors.
;The SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen.

$VirtY = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 79)    ;SM_CYVIRTUALSCREEN 79
;The height of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors.
;The SM_YVIRTUALSCREEN metric is the coordinates for the top of the virtual screen.

$Mons = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 80) ;SM_CMONITORS 80
;The number of display monitors on a desktop. For more information, see the Remarks section in this topic.

;Remarks
;System metrics can vary from display to display.
;GetSystemMetrics(SM_CMONITORS) counts only visible display monitors. This is different from EnumDisplayMonitors, which enumerates both visible display monitors and invisible pseudo-monitors that are associated with mirroring drivers. An invisible pseudo-monitor is associated with a pseudo-device used to mirror application drawing for remoting or other purposes.


$LSVS = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 76)     ;SM_XVIRTUALSCREEN 76
;The coordinates for the left side of the virtual screen. The virtual screen is the bounding rectangle of all display monitors.
;The SM_CXVIRTUALSCREEN metric is the width of the virtual screen.

$TSVS = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 77)     ;SM_YVIRTUALSCREEN77
;The coordinates for the top of the virtual screen. The virtual screen is the bounding rectangle of all display monitors.
;The SM_CYVIRTUALSCREEN metric is the height of the virtual screen.

$PriDispX = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 0)  ;SM_CXSCREEN 0
;The width of the screen of the primary display monitor, in pixels.
;This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES).

$PriDispY = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 1)  ;SM_CYSCREEN 1
;The height of the screen of the primary display monitor, in pixels.
;This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES).


$mz = "SM_CXSCREEN = "&$PriDispX[0] &"   SM_CYSCREEN = "&$PriDispY[0]
$m0 = "@DesktopWidth = "&@DesktopWidth &"   @DesktopHeight = "&@DesktopHeight
$m1 = "Number of visible screen monitors: " & $Mons[0]
$m2 = "Maximum size of 'virtual screen' : " & $VirtX[0] &"x"& $VirtY[0]
$m3 = "Full 'virtual screen' coordinates: " & $LSVS[0] &"," & $TSVS[0] &" to "& $VirtX[0] &","& $VirtY[0]
MsgBox(0+262144, "Status of determine screen sizes", $mz &@CRLF& $m0 &@CRLF& $m1 &@CRLF& $m2 &@CRLF& $m3)
Link to comment
Share on other sites

Do some more searching. I know there have been scripts posted that enumerate multiple monitors and get/set parameters for them.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks. Searching with "enumerate" brought up several however they appear to either bring up registry entries or query the monitor directly for serial number, etc. Still don't see resolution. I'll keep looking. Found WMI call for resolution but not setting it (http://www.autoitscript.com/forum/index.php?showtopic=82353&st=0&p=590685&#entry590685). Will keep looking later. Need to work now :)

Do some more searching. I know there have been scripts posted that enumerate multiple monitors and get/set parameters for them.

:(

Link to comment
Share on other sites

The attached UDF can change the resolution of multiple monitors and at one point I know I modified it to querry for the primary monitor so it shouldn't be hard to modify it for your neeeds

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Very nice routine.

The EnumDisplaySettings was the key. For others info is here: http://msdn.microsoft.com/en-us/library/dd162611%28VS.85%29.aspx

Also EnumDisplayDevices here: http://msdn.microsoft.com/en-us/library/dd162609%28v=VS.85%29.aspx

Thanks.

Also found routine here by xrxca that works well: http://www.autoitscript.com/forum/index.php?showtopic=82353&st=0&p=590685&#entry590685

Thanks - will give it a try later.

Edited by ahha
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...