Jump to content

Recommended Posts

Posted

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.

Posted

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)

 

  • 7 months later...
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...