Test for multiple monitors?

I’m writing a script that should only run if the user has only one monitor, and should refuse to run if multiple monitors are present.

Is there a way to test whether more than one monitor is active?

Many thanks…

Hi,

this is quite easy in Leopard:


tell application "System Events" to set numberOfDisplays to count desktops

or this version, which works also in Tiger


tell application "Image Events" to set numberOfDisplays to count displays

Thank you, Stefan! I was searching for “count monitors” - and I should have been searching for something that would count desktops…

I’m looking for a way to get number of displays which are currently turned ON. Your code returns “2” even if i have turned external display off (but it is still connected with cable to Mac).

Is the display still be indicated in the Preference Pane > Arrangement?
If not, you can check /Library/Preferences/com.apple.windowserver.plist or something else for the bounds.
If yes, I think there is no way to determine the power state of the display

Yes it is still in Arrangement.

Since external display eats RAM/CPU, maybe it can help somehow?

A display is hardware, it actually can’t eat RAM or CPU :wink: