MonitorGet

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

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

Parameters

N

Type: Integer

If omitted, the primary monitor will be used. Otherwise, specify the monitor number, between 1 and the number returned by MonitorGetCount.

&Left, &Top, &Right, &Bottom

Type: VarRef

If omitted, the corresponding value will not be stored. Otherwise, specify references to 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)

MonitorGetWorkArea, SysGet, Monitor functions

Examples

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.