I don't know AppleScript myself, which is why I came here to ask for help.
The workflow works like this. Keyboard shortcut > run usr/bin/osascript > play sound
this is the code inside the script (I didn't write it myself, found it on apple support forums and slightly modified it):
tell application "System Preferences"
reveal pane id "com.apple.preference.keyboard"
tell application "System Events"
tell process "System Preferences"
tell window "Keyboard"
tell tab group 1
click radio button "Dictation"
tell radio group 1
if value of radio button "On" is 0 then
click radio button "On"
click radio button "Off"
if sheet 1 exists then
tell sheet 1
click button "Enable Dictation"
repeat while sheet 1 exists
quit -- optional
Now the script does successfully toggle dictation, but whenever I turn dictation back on using the workflow, the spoken keyword phrase (which is found under system preferences > accessibility > dictation > [ ] enable the dictation keyword phrase) is disabled, even though the UI shows that it is enabled. I have to turn it off and on again to get it to work.
Could one of you tell me how I'd have to edit the script to make it so that dictation is turned back on with the keyword phrase still active?
My guess is that if "click radio button "Off" is performed, the script should also go into "Accessibility" and switch "enable the dictation keyword phrase" off and on again.
I'd really appreciate the help & think it wouldn't take very long to fix for someone who knows AppleScript.