Another UI script that would do the
trick<applescript://com.apple.scripteditor?action=new&script=tell%20application%20%22System%20Preferences%22%0D%09activate%0D%09set%20current%20pane%20to%20pane%20%22com.apple.preference.displays%22%0D%09tell%20application%20%22System%20Events%22%0D%09%09tell%20process%20%22System%20Preferences%22%0D%09%09%09click%20button%20%22Detect%20Displays%22%20of%20window%201%0D%09%09end%20tell%0D%09end%20tell%0D%09quit%0Dend%20tell>without
relying on showing displays in the menu bar.
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.displays"
tell application "System Events"
tell process "System Preferences"
click button "Detect Displays" of window 1
end tell
end tell
quit
end tell
Note that UI scripting requires "Enable access for assistive devices" be
selected in the Universal Access system preference pane.
- Hal
On Wed, Aug 24, 2011 at 2:10 PM, Rob McBroom <[email protected]>wrote:
> On Aug 24, 2011, at 11:30 AM, lloyd wrote:
>
> > One thing I would love to be able to do in a couple of keystrokes is
> > to "detect displays" (normally accessed by a button in the "displays"
> > pane of system preferences).
>
> There are a lot of examples of how to do that with AppleScript. Here’s one.
>
>
> http://top-frog.com/2010/10/06/applescript-to-detect-displays-on-snow-leopard/
>
> You could put a script like that in `~/Library/Scripts` and ensure that you
> have the “Scripts (User)” source enabled in the catalog. Most of the scripts
> I found seem to use the menu bar item rather than the button in System
> Preferences, so you might have to enable that too.
>
> --
> Rob McBroom
> <http://www.skurfer.com/>
>
>