Voorkeuren instellingscript

Is het mogelijk om een script te maken waarmee je een voorkeur instelling kunt automatiseren? Wat ik wil is dat je met een gedefinieerde knop(cominatie, ctrl-F15 bijv.) in het voorkeurpaneel "beeldschermen" het beeldscherm kunt detecteren. Van automator snap ik geen hout en met script editor gebeurt er niets als ik die handeling probeer op te nemen.

Gevonden op het [url=http://discussions.apple.com/thread.jspa?messageID=3233543][u:8b92ca34ac]Apple Discussions forum[/u:8b92ca34ac][/url]:

Topic: How to “Detect Displays” in AppleScript?

Q: I have a script that I run whenever I bring my AlBook to work; it configures networking and launches all my default apps. I also want it to do the “Detect Displays” command (from System Preferences -> Displays, the Displays menu icon, or anywhere else it might be found).

I have tried using (UI Elements Enabled) and menu item System Events, but cannot access the Displays menu icon (or any of the icon menus on the right side, for that matter). Can it be done?

A: Hello

Maybe this one may help:

–[SCRIPT]
property englishMsg : true (* true = english message, false = message français *)

tell application “System Events” to tell process “SystemUIServer”
try
set _ to get value of attribute “AXDescription” of every menu bar item of menu bar 1
on error
if englishMsg is true then
tell application (path to «constant afdregfp» as string) to ¬
display dialog “requires Mac OS X 10.4 or higher !” buttons {“Cancel”}
else
tell application (path to «constant afdregfp» as string) to ¬
display dialog “requiert Mac OS X 10.4 ou supérieur !” buttons {“Annuler”}
end if
end try

set j to 0
repeat with i from 1 to count of _
if _'s item i is “displays menu extra” then
set j to i
exit repeat
end if
end repeat
if j = 0 then return (* no Display menu *)

(* The Display menu is installed *)
tell menu bar item j of menu bar 1
click
delay 0.1
tell menu 1 to click menu item 1
end tell – to menu bar item…

end tell – to process and System Events
–[/SCRIPT]

Yvan KOENIG (from FRANCE vendredi 29 septembre 2006 18:20:41)