Getting current max screen size (identifying if multiple monitors present)

Started by gibberish, August 09, 2019, 08:35:26 AM

Previous topic - Next topic

gibberish

Script must identify where to position a window on screen.

If the third monitor is connected, it should position the window at "1400,200,1700,650".  However, if the 3rd monitor is not plugged it, the window should be positioned at "708,20,990,402".

How can I best determine if "1400,200,etc" is within the current visible area?

I tried WinMetrics(0) but that appears to report only the dimensions of the default (main) monitor in a multi-mon configuration.

td

Per the Consolidated WIL Help file documentation for the WinMetrics function:

  • 76  (Win2000 and newer) Coordinates for the left side of the virtual screen. (A virtual screen is actually the bounding rectangle of ALL the monitors.)
  • 77 (Win2000 and newer) Coordinates for the top of the virtual screen. (A virtual screen is actually the bounding rectangle of ALL the monitors.)
  • 78 (Win2000 and newer) Width of the virtual screen, in pixels. (A virtual screen is actually the bounding rectangle of ALL the monitors.)
  • 79 (Win2000 and newer) Height of the virtual screen, in pixels. (A virtual screen is actually the bounding rectangle of ALL the monitors.)
  • 80 (Win2000 and newer) Number of display monitors on the desktop

A few observations:
The values returned are not in WIL virtual coordinates so they need to be converted. 

Requests 78 and 79 produce some strange values if the system monitors are not all the same pixel width and height.   The strange results are not a WinBatch bug.  It is just what Windows reports.

Request 80 will count a monitor even if it is turned off on most systems.


This Tech Database article illustrates how to find the size of each monitor on a system:
https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UDF~-~UDS~Library/Windows~UDFs+udfEnumDisplayMonitors.txt   

The following Tech Database article discusses screen coordinates and how to convert them from one coordinate system to another:
https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+Tutorials+Screen~Coordinates~Explained.txt

I guess the short answer is that the process of finding a location on a display can get complicated.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

gibberish

Very helpful, many thanks.  I completely missed those options.

I was able to reliably solve my problem by using winMetrix(80) to get the number of monitors attached, plus the first several digits of the IP to identify home vs. office.