Workflow does not finish when initiated by dictation command

applescript

I created the following script to open up the dictation commands editor in system preferences. It works when I run it from within automator, but when I use a dictation command to initiate the workflow, it gets stuck after revealing the "Accessibility" pane. Any ideas?

tell application "System Preferences"
    activate
    reveal pane "Accessibility"
end tell

tell application "System Events" to tell process "System Preferences"
    delay 1
    select table 1 of scroll area 2 of window 1
    delay 1
    select row 14 of table 1 of scroll area 2 of window 1
    delay 0.5
    click button 2 of window 1
end tell

Best Answer

I had to give permission to "Dictation" setting under to System Preferences -> Security & Privacy -> Accessibility to get this to work.