rimmi2002

How to find out total number of monitors

5 posts in this topic

Hi I am writing a script and I'd like it to behave differently based on the # on monitors attached. Is there a way to find this out by an Autoit command? Thanks.

Share this post


Link to post
Share on other sites



Look at the _WinAPI_EnumDisplayMonitors() function, the top line returned gives you the count of monitors.

Share this post


Link to post
Share on other sites

Also see _WinAPI_GetSystemMetrics()

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
; From https://www.autoitscript.com/forum/topic/134534-_desktopdimensions-details-about-the-primary-and-secondary-monitors/

Local $a[] = [_WinAPI_GetSystemMetrics($SM_CMONITORS), _ ; Number of monitors.
        _WinAPI_GetSystemMetrics($SM_CXSCREEN), _ ; Width or Primary monitor.
        _WinAPI_GetSystemMetrics($SM_CYSCREEN), _ ; Height or Primary monitor.
        _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN), _ ; Width of the Virtual screen.
        _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)] ; Height of the Virtual screen.

ConsoleWrite("Number of monitors = " & _WinAPI_GetSystemMetrics($SM_CMONITORS) & @CRLF)
_ArrayDisplay($a)

 

Share this post


Link to post
Share on other sites

Thanks for the help. 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

(a bit late but good information)
_WinAPI_GetSystemMetrics(80) gives you the number of active monitors

 

 

#NoTrayIcon
#include <WinAPI.au3>
$aDevice = _WinAPI_GetSystemMetrics(80)
if $adevice = 1 Then

... (enter your intended action here if one monitor is present)

EndIf

Edited by NaX
clarity

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now