Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript help (run as application)

I used Automater to write this script:



tell application "System Events"

tell tab group 1 of window "Keyboard" of process "System Preferences"

click checkbox "Use all F1, F2, etc. keys as standard function keys"

end tell

end tell



I save this as an Application, but when I run the application, I get an error.

"The action “Run AppleScript” encountered an error."


Is there anyone who can tell me how to fix this?


I log in remotely for work on a Windows-PC where I use Excel a lot.

I really would love to have a script to quick-change my Function-key settings.

MacBook Pro, Mac OS X (10.0.x)

Posted on Feb 9, 2016 1:58 PM

Reply
8 replies

Feb 9, 2016 11:45 PM in response to onlinestephan

You need to show the particular preference window before targeting it:


tell application "System Preferences"
  activate
  reveal anchor "keyboardTab" of pane id "com.apple.preference.keyboard"
end tell

tell application "System Events"
  tell tab group 1 of window "Keyboard" of process "System Preferences"
  click checkbox "Use all F1, F2, etc. keys as standard function keys"
  end tell
end tell

Feb 10, 2016 8:52 AM in response to Pierre L.

Hey guys,


Thnx for the help so far.


I copied this into AppleScripteditor:


tell application "System Preferences"

reveal anchor "keyboardTab" of pane id "com.apple.preference.keyboard"

end tell


tell application "System Events"

tell tab group 1 of window "Keyboard" of process "System Preferences"

click checkbox "Use all F1, F2, etc. keys as standard function keys"

end tell

end tell


Saved it as an Application


Got this response.


System Events got an error: test is not allowed assistive access. (-1728)


Almost, there, anyone for the last bit of help?

Applescript help (run as application)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.