MonitorGet

Checks if the specified monitor exists and optionally retrieves its bounding coordinates.

ActualN := MonitorGet(N, Left, Top, Right, Bottom)

Parameters

N

Type: Integer

The monitor number, between 1 and the number returned by MonitorGetCount. If omitted, the primary monitor is used.

Left
Top
Right
Bottom

Type: Variable

The output variables in which to store the bounding coordinates, in pixels.

Return Value

Type: Integer

This function returns the monitor number (the same as N unless N was omitted).

Error Handling

On failure, an exception is thrown and the output variables are not modified.

Remarks

The built-in variables A_ScreenWidth and A_ScreenHeight contain the dimensions of the primary monitor, in pixels.

SysGet can be used to retrieve the bounding rectangle of all display monitors. For example, this retrieves the width and height of the virtual screen:

MsgBox SysGet(78) " x " SysGet(79)

Related

MonitorGetWorkArea, SysGet, Monitor functions

Examples

#1: Shows the bounding coordinates of the second monitor in a message box:

try
{
    MonitorGet(2, Left, Top, Right, Bottom)
    MsgBox "Left: " Left " -- Top: " Top " -- Right: " Right " -- Bottom: " Bottom
}
catch
    MsgBox "Monitor 2 doesn't exist or an error occurred."

See example #1 on the Monitor Functions page for another demonstration of this function.