Here's my version of the script, utilizing UI Scripting & the Displays
Pref Pane (no need for the menubar item). You will have to update the
window name inside the quotes of the line: (tell button "Detect
Displays" of window "DELL SP2309W" to click). For example, my MBP's
window name is the generic "Color LCD".

But sometimes this can be harder to find than you'd think; one of my
old no-name monitors had a trailing space at the end of it's name. So
while I typed in what I thought was the window name, I kept getting
errors. I had to use a uielementinspector program (whose name escapes
me at the moment) to find the actual name, with the "invisible" space.

Anyway, let me know if it works out for you!


CODE BELOW:
-----------


(*              Use this instead if you're running 10.5 or lower

                tell button "Detect Displays" of group 1 of tab group 1 of 
window
"DELL SP2309W" to click
*)
tell application "System Preferences" to activate

tell application "System Events"
        tell process "System Preferences"
                click menu item "Displays" of menu "View" of menu bar 1
                delay 3
                tell button "Detect Displays" of window "DELL SP2309W" to click
                delay 3
        end tell
end tell

ignoring application responses
        tell application "System Preferences" to quit
end ignoring



----------
CODE ABOVE

Reply via email to