*Attention* A simple VoiceOver Reboot Applescript

By Brian, 10 October, 2023

Forum
macOS and Mac Apps

Hey guys and gals,

I've come across a number of posts where, for whatever reason, someone mentioned they wished there was a quick and easy way to reboot VoiceOver.
Well, I am here to save the day! πŸ¦ΈπŸ»β€β™‚οΈ

Just copy the code below exactly as is, and paste into a new script. Best used with Keyboard commander.
The first time you run it through a commander, you will get a security message to allow something called "Scrod" to control your computer. This is normal. It is located in the Security and Privacy setting > Privacy > Accessibility, and all this does is press "command + f5" for you twice, with a short delay in-between.
Note: I posted this as a reply in another thread, but felt it might get more traction on its own. πŸ˜‡

# A small script to restart VoiceOver.
# You can place a "#" sign in front of the first line if you do not want speech, or simply replace "Daniel" with a different voice.
# Remember to keep the name of the voice spelled properly with a capital first letter.
# Finally you can play with the numbers for rate and volume, but the volume cannot go above "1". You can do a point value, to lower volume, however.

say "Restarting VoiceOver" using "Daniel" speaking rate 265 volume 1
tell application "System Events" to key code 96 using command down
delay 1
tell application "System Events" to key code 96 using command down

# End of script.

Options

Comments

By mr grieves on Thursday, October 26, 2023 - 17:24

Thanks very much for posting this!

A couple of things to add:

I had to change delay to 2.5 for it to finish restarting. I guess it's just something that needs to be tinkered with to suit.

The security dialog is one of those odd background things that always confuses me. I didn't think it had worked then I noticed my Mac going ping from time to time. So bringing up the application chooser with VO+F1 makes it easy to select as I don't think it appears in Cmd+Tab.

I think you also need to be careful not to be holding down any other keys when it's running. One time maybe I was still holding down right option and it turned VoiceOver off, said something that meant nothing to me and then stopped. And then it kept popping up a message telling me to turn off capas lock which I seeme to have no option but to comply with. Not sure what I've now done.

Can the script instruct Vocivoiceover to turn on anad off specifically without using key strokes?

By mr grieves on Thursday, October 26, 2023 - 17:24

Oh yes it was accessibility shortcuts I accidentally summoned which is right option+cmd+f5. So if using this script make sure you let go of right option before Daniel stops talking or it all goes a bit pear shaped.

Not sure where this caps lock thing has come from. I have caps lock and option+ctrl both as VO modifiers and caps lock still works, but if I double press it to toggle caps lock, I now get a dialog telling me that it is going to turn it off. No idea where this has come from!

By Brian on Thursday, October 26, 2023 - 17:24

Not sure what exactly is going on with your setup. However, I tend to use "both" Option keys for KB Commander. I'm dirty like that.

By Brian on Thursday, October 26, 2023 - 17:24

I will have to look into that. . . .
Stay tuned!.

By PaulMartz on Thursday, October 26, 2023 - 17:24

I saw this earlier, but thanks for posting it in a separate thread for greater visibility

I use a few scripts that invoke keypresses, and I tied them to keyboard shortcuts that involve modifier keys. I discovered it's very important to release those modifier keys so that they don't affect the key commands in the script. Seems like a bug to me, but I guess it could be a feature.

Best solution is to associate a script like this to a hot key that doesn't involve a modifier.

By Brian on Thursday, October 26, 2023 - 17:24

I currently have this as a Keyboard Commander shortcut. The keys are:
Option + Shift + "R".

Though as I mentioned above, I use both Option keys for KB commander. πŸ€·πŸ»β€β™‚οΈ