Check if new monitor is connected

Hi - is there any chance to let the system check, if a second display is connected?

i like to change the display profile then to sRGB, even if I don’t know, what kind of display is connected.

Thanks - Leovinus.

I don’t have two monitors so I don’t know for sure if this works, but

tell application "System Profiler"
	set s to system profile
end tell

set {saveDelims, text item delimiters} to {text item delimiters, "Display:" & (ASCII character (10))}

set nDisplays to (count of text items of s) - 1
set text item delimiters to saveDelims
nDisplays

might do it, or at least something close to this.

  • Dan

Try this. Thus, i have 2 Displays connected to my PB 1.5 & this script rtns 1 & 2 when only 1 & a 2nd Display is connected respectively: -

(* This script demonstrates how to Rtn the Num of Monitors Attached to Target Sys Incl Displays Connected to
     the S-Vid Interface - Using the "System Profiler" App. *)



(* Note: As ur prob aware AS doesn't implement Boolean Test Specifiers for its own lists, otherwise the 
    following satatement could have been employed: -

    tell mySysProfile to return items whose text contains "Resolution: "

    What's more, the "System Profiler" app also doesn't appear to support this Test Specifier. Hence, this -
    (long-winded) Native Approach. *)



-->Used to Migrate Data Rtned by sys profile to list - Data by default is rtned as unicode txt
set text item delimiters to ASCII character 10

tell application "System Profiler" to set mySysProfile to system profile

-->Migrates Class Unicode Txt to List Struct
set mySysProfile to text items of mySysProfile

-->Intialise monitorCount to 0 as it'll be used by Repeat Loop to Count Num of Monitors on ur sys
set monitorCount to 0


-->Repeat Loop processes all items in mySysProfile's List
repeat with i from 1 to (count mySysProfile)
	
	--> Tests whether item being processed is Monitor -
	(* Note: "Resolution:" Str is used as this Appears according Num of Monitors attached to ur Sys. Whereas,
        Strs: "Display" &/or "Display Type:" appear multi times throughout list even if only 1 Monitor is attached. *)
	if (item i of mySysProfile contains "Resolution:") then
		
		-->Debug Code: Where i is the location of the Monitor
		display dialog "val of i is: " & i & return & item i of mySysProfile
		set monitorCount to monitorCount + 1
	end if
	
end repeat

end

-->Returns Result via Display Dialog
display dialog "U have " & monitorCount & " Monitor(s) currently connected to ur sys"

great, this works - thank you.

(for other - non-english - users: the only point I had to change was to translate “resolution” into german.)

leovinus

“screen list” is a command from Jon’s Commands.osax. It returns a list of records for each screen where the records include Screen ID, Bounds, Color Depth, in Color, has menu bar, refresh rate, resolution index, safe resolution, and screen size, to name just some of them. With that installed this gives the number of screens:

count of screen list