I have the following AppleScript which toggles the scroll direction on the trackpad:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.trackpad"
end tell
tell application "System Events"
tell process "System Preferences"
click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad"
click checkbox 1 of tab group 1 of window "Trackpad"
end tell
end tell
tell application "System Preferences"
quit
end tell
This script runs without issues when the "play" button in Automator is used to execute it. However, when I make a service that runs it and assigned a keyboard shortcut to the service, it fails to run via the keyboard shortcut.
Wrapping it in a try
block with some error reporting yields the following:
Automator Runner is not allowed assistive access.
Error number-1728
I found Automator Runner.app and gave it assistive access using the instructions found here.
It now appears with a checked box in the list of applications with assistive access:
However, the issue persists. I continue to get the same message notifying me that Automator Runner is not allowed assistive access.
when trying to run the script using the keyboard command of the service that runs the script.
Update
I just succeeded at implementing this alternative script to accomplish the same thing, but it also only works when Automator has focus and has the same issue when it does not:
tell application "System Preferences"
reveal anchor "trackpadTab" of pane "com.apple.preference.trackpad"
end tell
tell application "System Events" to tell process "System Preferences"
click checkbox 1 of tab group 1 of window 1
end tell
quit application "System Preferences"