WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: gibberish on August 09, 2019, 08:35:26 AM

Title: Getting current max screen size (identifying if multiple monitors present)
Post by: gibberish on August 09, 2019, 08:35:26 AM
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.
Title: Re: Getting current max screen size (identifying if multiple monitors present)
Post by: td on August 09, 2019, 09:45:21 AM
Per the Consolidated WIL Help file documentation for the WinMetrics function:

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 (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 (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.
Title: Re: Getting current max screen size (identifying if multiple monitors present)
Post by: gibberish on August 09, 2019, 09:52:03 AM
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.