Enable Voice Control

I try to create an Apple Script to Enable Voice Control in a Mac.

This is in: System Preferences > Accessibility > Voice Control > Enable Voice Control

I think I get close. But I do not know how to call the left menu “Voice control”

This is what I have tried and do not work:

    tell application "System Events"
    	click checkbox "Enable Voice Control" of window "Voice Control" of window "Accessibility" of application process "System Preferences" of application "System Events"
    end tell

I am on Catalina. This works:


tell application "System Preferences"
	reveal anchor "Seeing_VoiceOver" of pane id "com.apple.preference.universalaccess"
	activate
	repeat until exists window "Accessibility"
		delay 0.1
	end repeat
end tell

tell application "System Events" to tell application process "System Preferences"
	tell window "Accessibility" to click checkbox "Enable VoiceOver" of group 1
end tell

tell application "System Preferences" to quit

You are doing VoiceOver, I am asking for Voice Control

I cannot adapt. Thank you anyway


tell application "System Preferences"
	reveal anchor "Dictation" of pane id "com.apple.preference.universalaccess"
	activate
	repeat until exists window "Accessibility"
		delay 0.1
	end repeat
end tell

tell application "System Events" to tell application process "System Preferences"
	tell window "Accessibility" to click checkbox "Enable Voice Control" of group 1
end tell

tell application "System Preferences" to quit

It works well. Thank you. But there are many things I do not understand. For instance, why reveal anchor “Dictation” ? Where does Dictation come from?

The “System Preferenses” application has 32 panes. This is the window that you see when you open the application. Clicking on the icon of a specific pane opens the corresponding window with elements (on left) called anchors:


tell application "System Preferences" to get panes

→ {pane id “com.apple.preference.universalaccess” of application “System Preferences”, pane id “com.apple.preferences.AppleIDPrefPane” of application “System Preferences”, pane id “com.apple.preferences.Bluetooth” of application “System Preferences”, pane id “com.apple.preference.digihub.discs” of application “System Preferences”, pane id “com.apple.preference.datetime” of application “System Preferences”, pane id “com.apple.preference.desktopscreeneffect” of application “System Preferences”, pane id “com.apple.preference.displays” of application “System Preferences”, pane id “com.apple.preference.dock” of application “System Preferences”, pane id “com.apple.preference.energysaver” of application “System Preferences”, pane id “com.apple.preferences.extensions” of application “System Preferences”, pane id “com.apple.preferences.FamilySharingPrefPane” of application “System Preferences”, pane id “com.apple.preference.general” of application “System Preferences”, pane id “com.apple.preferences.internetaccounts” of application “System Preferences”, pane id “com.oracle.java.JavaControlPanel” of application “System Preferences”, pane id “com.apple.preference.keyboard” of application “System Preferences”, pane id “com.apple.Localization” of application “System Preferences”, pane id “com.apple.preference.expose” of application “System Preferences”, pane id “com.apple.preference.mouse” of application “System Preferences”, pane id “com.apple.preference.network” of application “System Preferences”, pane id “com.apple.preference.notifications” of application “System Preferences”, pane id “com.apple.preference.printfax” of application “System Preferences”, pane id “com.apple.preference.screentime” of application “System Preferences”, pane id “com.apple.preference.security” of application “System Preferences”, pane id “com.apple.preferences.sharing” of application “System Preferences”, pane id “com.apple.preference.speech” of application “System Preferences”, pane id “com.apple.preferences.softwareupdate” of application “System Preferences”, pane id “com.apple.preference.sound” of application “System Preferences”, pane id “com.apple.preference.spotlight” of application “System Preferences”, pane id “com.apple.preference.startupdisk” of application “System Preferences”, pane id “com.apple.prefs.backup” of application “System Preferences”, pane id “com.apple.preference.trackpad” of application “System Preferences”, pane id “com.apple.preferences.users” of application “System Preferences”}


tell application "System Preferences" to get anchors of pane id "com.apple.preference.universalaccess"

→ {anchor “Accessibility_Shortcut” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Seeing_Cursor” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Seeing_Zoom” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Keyboard” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Seeing_VoiceOver” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Virtual_Keyboard” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “TextToSpeech” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Dwell” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Dictation” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Switch” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Siri” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Alternate_Pointer_Actions” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Mouse” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Captioning” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Media_Descriptions” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Head_Pointer” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “General” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Seeing_ColorFilters” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Seeing_Display” of pane id “com.apple.preference.universalaccess” of application “System Preferences”, anchor “Hearing” of pane id “com.apple.preference.universalaccess” of application “System Preferences”}

See also scripts from @me and from Peavine@, here - “System Preference dialog”

Thank you. I want to learn. For instance: that opens the window I want:

reveal anchor "Dictation" of pane id "com.apple.preference.universalaccess"

But why do they call it Dictation in Apple Script and Voice Control in the window? Where did you find that information?

I still do not understand how it works and I would not be able to make another script for a similar problem. I like all this and I want to learn.

Yes, I also noticed that there is one name on the window, and another name in the anchor lists of the pane. This kind of confusion is common in applications.

In such cases, I usually use Sherlock Holmes’ logical exclusion method. Since the names of other anchors are close to what is visible to the eye in the window, I excluded them and only “Dictation” remained.


tell application "System Preferences"
	activate
	-- select the pane from list that You want
	-- see https://developer.apple.com/documentation/devicemanagement/systempreferences?language=objc
	set the current pane to pane id "com.apple.preference.universalaccess"
	-- get the name of the avalable anchors
	get the name of every anchor of pane id "com.apple.preference.universalaccess"
	--> returns: {"Accessibility_Shortcut", "Seeing_Cursor", "Seeing_Zoom", "Keyboard", "Seeing_VoiceOver", "Virtual_Keyboard", "TextToSpeech", "Dwell", "Dictation", "Switch", "Siri", "Alternate_Pointer_Actions", "Mouse", "Captioning", "Media_Descriptions", "Head_Pointer", "General", "Seeing_ColorFilters", "Seeing_Display", "Hearing"}
end tell

Does “of group 1” make reference to the first part of the script? Where can I learn more about how to use that?

See: UI Browser (https://pfiddlesoft.com/uibrowser) or use the Accessibility Inspector from Xcode.

get the name of every anchor of pane id “com.apple.preference.universalaccess”

That is very useful. Thank you!

For the other things I also use the UI Browser. Without such a tool it is almost impossible to find out for example if a check field is in a group or not. Try it out. There is a trial version for 30 days and it can generate AppleScript code.

Is it possible to add at the end the possibility of “go to sleep”?
I mean, click to the button “Sleep” with an script