help needed doing a few things in Apple Script.

By Justin Harris, 4 May, 2020

Forum
macOS and Mac Apps

Hey folks,
This one is for more power users. I am pretty decent on the mac, but have never messed with Apple script, and don't want to mess anything up. However, there are a few things I would like to accomplish.
1. Using the keyboard commander, option + t makes voiceover read the time. This is a nice keyboard shortcut, but the problem is it reads the date too, which makes it rather long. All I want is the time, plus am or pm. Simple and quick. But I don't know how to appropriately modify the existing script.
2. I would like to have a script that would let me have voiceover announce battery percentage plus time left if available. Again, no idea how to make that happen. Once it's set up, I can go in to keyboard commander and set it to option + B. If you could help out, I would really appreciate it.
Thanks,
Justin

Options

Comments

By Carlos Taylor on Thursday, May 28, 2020 - 19:37

I have the scripts that Bryan Smart put out several years ago. I find that his script for time and date works better than the one that comes from Apple. He also has a script to report battery level. Here is the direct link to download his scripts.

http://bryansmart.com/files/BSmart%20VoiceOver%20Scripts.zip

By Carlos Taylor on Thursday, May 28, 2020 - 19:37

I forgot to mention that I don't see why you couldn't modify the script and delete the section that announces the date. Make a copy of the script so you have the original if things don't go as planned, play with modifying it in script editor which you can find in the utilities menu, and see how far you get. Keep in mind that you can run the script to see if it will work directly from Script Editor. This is a huge time saver as you don't have to assign it to VoiceOver's keyboard commander just to see if it works.

By Justin Harris on Thursday, May 28, 2020 - 19:37

Hey, I had heard about these scripts before but when I tried to download the link was broken. Much appreciated.

By Justin Harris on Thursday, May 28, 2020 - 19:37

Ok so I imported these, but they don't seem to work. Not sure why. I am running Katalina on a 2015 MacBook pro. I use the computer in Spanish. Would that make any difference?

By Carlos Taylor on Thursday, May 28, 2020 - 19:37

I would think it would work to some degree, but I don't know for sure. I've only used the scripts in English. I placed mine in the VoiceOver folder in library/scripts/VoiceOver. I then made sure to check the checkbox to allow VoiceOver to be controlled with AppleScript in the general category of VoiceOver preferences. Then, from the commanders category, I selected the keyboard commander tab, set my hot key, and browsed the to the folder where I saved the scripts. It works fine here. Does your's do nothing at all?

By Carlos Taylor on Thursday, May 28, 2020 - 19:37

I just opened the time and date script in ScriptEditor, pressed command+r to run the script and the current time and date were announced as expected. Try doing the same on your system to make sure the script works by itself.

By Justin Harris on Thursday, May 28, 2020 - 19:37

So, it now works. Had to go in and check that box in vo settings. So, they read out in English. I'm really nervous to mess with anything because I have never done anything at all with Apple Script. Do you know what part of the script I need to change to have it work in Spanish? If not, at least this is better than nothing.

I'm glad you were able to get it to work. I literally took a look at apple script for the first time a week ago. it's nothing I'm really familiar with. The only thing I can suggest is to take a look at in ScriptEditor and see if any thing makes sense to you. As I said before, I suggest playing with a copy of the script file so you don't accidentally ruin the original. Most of apple script is done in a way that is somewhat understandable. I was at least able to eliminate the date announcement without too much trouble. I just wanted to see how easy it would be to do, but I personally don't mind the date announcement so left it in on my system.