MonitorGet

Retrieves screen resolution and multi-monitor info.

Exists  := MonitorGet(N, Left, Top, Right, Bottom)
Exists  := MonitorGetWorkArea(N, Left, Top, Right, Bottom)
Count   := MonitorGetCount()
Primary := MonitorGetPrimary()
Name    := MonitorGetName(N)

Parameters

N

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

Left
Top
Right
Bottom

Output variables which receive bounding coordinates as described below.

Exists
Count
Primary
Name

An output variable or the return value of the function, as described below.

MonitorGet

Checks for the existence of monitor number N and optionally retrieves its bounding coordinates. The information is stored in up to four variables passed as parameters. If N is too high or there is a problem retrieving the info, the variables are all made blank and the return value is false. For example:

if MonitorGet(2, Left, Top, Right, Bottom)
    MsgBox "Left: " Left " -- Top: " Top " -- Right: " Right " -- Bottom: " Bottom
else
    MsgBox "Monitor 2 doesn't exist or an error occurred."

MonitorGetWorkArea

Same as the above except the area is reduced to exclude the area occupied by the taskbar and other registered desktop toolbars.

MonitorGetCount

Retrieves the total number of monitors. Unlike the SM_CMONITORS sub-command of SysGet, the return value includes all monitors, even those not being used as part of the desktop.

MonitorGetPrimary

Retrieves the number of the primary monitor, which will be 1 in a single-monitor system.

MonitorGetName

Retrieves the operating system's name for monitor number N.

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

DllCall, WinGet, SysGet

Examples

; This is a working script that displays info about each monitor:
MonitorCount := MonitorGetCount()
MonitorPrimary := MonitorGetPrimary()
MsgBox "Monitor Count:`t" MonitorCount "`nPrimary Monitor:`t" MonitorPrimary
Loop MonitorCount
{
    MonitorGet A_Index, L, T, R, B
    MonitorGetWorkArea A_Index, WL, WT, WR, WB
    MsgBox Format("
    (
        Monitor:`t#{1}
        Name:`t{2}
        Left:`t{3} ({4} work)
        Top:`t{5} ({6} work)
        Right:`t{7} ({8} work)
        Bottom:`t{9} ({10} work)
    )", A_Index, MonitorGetName(A_Index), L, WL, T, WT, R, WR, B, WB)
}