An AppleScript to detect displays when operating blind
Jan 15, '04 08:53:00AM • Contributed by: scottcarney
So I recently had a rather unpleasant conference experience. I plugged my old Ti PowerBook into the supplied projector. The PowerBook found the projector and made the projector the main display. Unfortunately, the projector just gave a blue screen. I needed to reset the resolution. OK, fine, except the menu bar, dock and all icons are now in the blue. I unplug the PowerBook from the projector: nada, nothing, no change, zippo -- the PowerBook still seems to think it is talking to the projector. I hate to say it, but for the first and only time in my many years of Mac ownership, I thought, "If this were a PC, I could hit one of the function keys and my problem would be solved." I could not think of a decent solution on the spot, so I wound up doing a forced restart. It took forever, all in front of a couple of hundred people. Never again...
Anyway, here's my fix: I wrote this simple script
tell application "System Preferences"
set current pane to pane "com.apple.preference.displays"
tell application "System Events"
tell process "System Preferences"
click button "Detect Displays" of group 1 of ¬
tab group 1 of window "Color LCD"
Then, using Key Xing (there are other applications you could use), I set Shift-F12 to run the script from anywhere. This would have fixed my problem after I unplugged the projector ... BTW, if anyone from Apple is listening, the Keyboard Shortcuts pane in 10.3 is a sick joke. I should have been able to set this up with a couple of mouse clicks. Grrr...