AppleScript Setting Select Drop Down
Solution 1:
Using the shell Defaults command in an Applescript Do shell script seems to work ok for me. This will save on GUI scripting problems.
The script first reads the preference file. Then sets it to the opposite of its Bool.
set dictionToggle to (do shell script " defaults read ~/Library/Preferences/com.apple.assistant.support \"Dictation Enabled\" ") as integer
do shell script "defaults write ~/Library/Preferences/com.apple.assistant.support \"Dictation Enabled\" -bool " & (not (dictionToggle as boolean)) as Unicode text
I always backup any preference files using the contextual menu compress "…." to make a zipped copy of it.
The file com.apple.assistant.support.plist that is changed is found in your preferences folder
/Users/UserName/Library/Preferences/com.apple.assistant.support.plist
If you have to use GUI scripting especially if you want to change the short cut keys. ( and since I cannot be Ars… to figure out which one of the symbolic hotkey settings in the com.apple.symbolichotkeys.plist is the right one)
Then this should work. (as it does on my Mac at least :-) )
set off to 1
set fnTwice to 3
set rightCommandTwice to 4
set leftCommandTwice to 5
set eitherCommandTwice to 6
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.speech"
reveal (first anchor of current pane whose name is "Dictation")
end tell
tell application "System Events"
tell application process "System Preferences"
set theGroup to tab group 1 of window "Dictation & Speech"
click radio button "On" of radio group 1 of theGroup
try
click button "Enable Dictation" of sheet 1 of window "Dictation & Speech"
end try
set thePopUp to pop up button 2 of theGroup
click thePopUp
click menu item fnTwice of menu 1 of thePopUp
end tell
end tell
tell application "System Preferences"
--quit
end tell