apple scripts for VoiceOver

Forum
macOS and Mac Apps

Hi everyone,
I recently had to do a reinstall of Mac OS, and lost some scripts I had. I don't really know how to successfully modify existing scripts or how to create new ones.
I already have the script to make Voiceover say the time, and that works okay, but would like to modify it so it doesn't also read the date, as I don't need that info. I want just the time. If anyone has a modified script that would do the trick, please let me know. Also, I used to have a script that would read battery status. If anyone has that and could pass it along, it would be much appreciated.

Options

Comments

Submitted by David Goodwin👨‍🦯 on Wednesday, August 11, 2021

Member of the AppleVis Editorial Team

The following script will speak the time in 12 hour format using the Ava voice. Simply swap out “Ava” for your own preferred voice.

set currentDate to current date
set amPM to "AM"
set currentHour to (currentDate's hours)
set currentMinutes to currentDate's minutes

if (currentHour ≥ 12 and currentHour < 24) then
set amPM to "PM"
else
set amPM to "AM"
end if

-- make minutes below 10 sound nice
if currentMinutes < 10 then
set currentMinutes to ("0" & currentMinutes) as text
end if

-- ensure 0:nn gets set to 12:nn AM
if currentHour is equal to 0 then
set currentHour to 12
end if

-- readjust for 12 hour time
if (currentHour > 12) then
set currentHour to (currentHour - 12)
end if

set currentTime to "The current time is " & (currentHour as text) & ":" & ((currentMinutes) as text)

say currentTime using "Ava"
delay 2

Submitted by David Goodwin👨‍🦯 on Wednesday, August 11, 2021

Member of the AppleVis Editorial Team

The following script will speak the remaining battery percentage using the Ava voice. Simply swap out “Ava” for your own preferred voice.

set maxCapacity to do shell script "ioreg -w0 -l | grep \"\\\"MaxCapacity\\\" = \""
set maxLevel to the last word of maxCapacity
set curCapacity to do shell script "ioreg -w0 -l | grep \"\\\"CurrentCapacity\\\" = \""
set curLevel to the last word of curCapacity
set battPct to round (100 * curLevel / maxLevel)
set output to "Battery " & battPct & "%"
say "Battery " & battPct & "%" using "Ava"

Submitted by Wenwei on Friday, May 13, 2022

Hi, thank you for providing these scripts. I have a question. I copied these scripts exactly as written in the script editor but they don't appear when I try to assign a commander to run them. I was wondering if you'd be willing to briefly clarify what I need to paste into the script source and script description fields? Thanks in advance!