Script Extras
Here are some AppleScript script tools (macOS) for working with Voice Control and commands files.
Show Voice Control Preferences
Simple script executes a special Apple URL to display the Voice Control tab of the Accessibility system preferences pane.
To install, place the AppleScript script file in the Home ▶︎ Library ▶︎ Scripts folder on your computer. If there is no Scripts folder, make a new one. Next activate the system-wide Script Menu from the General Preferences in the Script Editor application that comes with macOS (Application ▶︎ Utilities folder). Installed scripts will be available from the activated Script Menu in the top right menu bar.
Show Voice Control Preferences
open location "x‑apple.systempreferences:
com. "apple. preference. universalaccess? Dictation
Toggle Voice Control
This script uses the System Events application (UI Scripting) to enable and disable Voice Control in the system preference pane.
NOTE: Requires the one-time approval of Apple Events access in the security dialog displayed during the 1st run of the script.
To install, place the AppleScript script file in the Home ▶︎ Library ▶︎ Scripts folder on your computer. If there is no Scripts folder, make a new one. Next activate the system-wide Script Menu from the General Preferences in the Script Editor application that comes with macOS (Application ▶︎ Utilities folder). Installed scripts will be available from the activated Script Menu in the top right menu bar.
Toggle Voice Control
tell application "System Preferences"
activate
try
set the current pane to pane id "com.apple.preference.universalaccess"
delay 1
reveal anchor "Dictation" of the current pane
tell application "System Events"
tell process "System Preferences"
repeat with i from 1 to 30
if exists checkbox "Enable Voice Control" of group 1 of window 1 then
exit repeat
end if
if i is 15 then error "There was a problem accessing the Voice Control preference pane."
delay 0.5
end repeat
click checkbox "Enable Voice Control" of group 1 of window 1
end tell
end tell
delay 1
quit
on error errMsg
display alert "ERROR" message errMsg
end try
end tell
Generate Custom Command ID
This script will generate a Custom Voice Control Command Identifier and place it on the clipboard.
To install, place the AppleScript script file in the Home ▶︎ Library ▶︎ Scripts folder on your computer. If there is no Scripts folder, make a new one. Next activate the system-wide Script Menu from the General Preferences in the Script Editor application that comes with macOS (Application ▶︎ Utilities folder). Installed scripts will be available from the activated Script Menu in the top right menu bar.
Generate Custom Command ID
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
-- classes, constants, and enums used
property NSNumberFormatter : a reference to current application's NSNumberFormatter
property NSString : a reference to current application's NSString
set IDString to ("Custom." & generateAbsoluteTimeID()) as string
set the clipboard to IDString
display dialog "The following key is on the clipboard:" & linefeed & linefeed & IDString with title "Voice Control Command ID" buttons {"OK"} default button 1
on generateAbsoluteTimeID()
## 669490008.038141
set currentAbsoluteTime to current application's CFAbsoluteTimeGetCurrent()
set fmtr to NSNumberFormatter's new()
fmtr's setFormat:"#.#########"
set exportDateString to NSString's stringWithFormat_("%@", fmtr's stringFromNumber:currentAbsoluteTime) as string
if length of exportDateString is not 23 then
repeat until length of exportDateString is 18
set exportDateString to exportDateString & (random number from 1 to 9) as string
end repeat
end if
return exportDateString
end generateAbsoluteTimeID
“The power of the computer should reside in the hands of the one using it. — Sal Soghoian”
LEGAL
Copyright 2022 Sal Soghoian (Nyhthawk Productions)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. VOICE-CONTROL.ORG assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. VOICE-CONTROL.ORG provides this only as a convenience to our users. VOICE-CONTROL.ORG has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and VOICE-CONTROL.ORG assumes no responsibility in this regard. Please understand that a third-party site is independent from VOICE-CONTROL.ORG and that VOICE-CONTROL.ORG has no control over the content on that website. Please contact the vendor for additional information.