By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Getting the desktop dimension using AutoIt

How to get the dimension of the screen with AutoIt, both for single and multiple-display monitor environments.

Edited: 2014-06-05 18:56

To get the dimensions of the main screen, you can use the @DeskTopHeight and @DeskTopWidth macros. These do not however, return the dimensions of multiple monitors.

MsgBox(0, "Result", @DeskTopWidth & "x" & @DeskTopHeight)

Multiple monitors

Retrieving the dimensions of multiple monitors can be done using the _WinAPI_ functions, just remember to include the WinAPI.au3 file.

You can get the number of monitors using the _WinAPI_GetSystemMetrics function.

#include <WinAPI.au3>
MsgBox(0, "Result", _WinAPI_GetSystemMetrics(80))

To get the width and height of all monitors combined, you can use the below code.

#include <WinAPI.au3>
MsgBox(0, "Result", _WinAPI_GetSystemMetrics(78) & "x" & _WinAPI_GetSystemMetrics(79))

The problem with this method is that it gives the dimensions of all monitors, which makes it difficult to know the dimensions of the individual monitors.