Tuesday, May 11, 2021

#1 2021-03-14 09:20:17 am

NMG
Member
Registered: 2019-09-29
Posts: 54

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:

Applescript:

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

Last edited by NMG (2021-03-14 09:22:09 am)


Filed under: system preferences

Offline

 

#2 2021-03-15 09:18:46 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1797

Re: Enable Voice Control

I am on Catalina. This works:

Applescript:


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


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2021-03-15 10:42:48 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Enable Voice Control

You are doing VoiceOver, I am asking for Voice Control

I cannot adapt. Thank you anyway

Offline

 

#4 2021-03-15 12:15:44 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1797

Re: Enable Voice Control

NMG wrote:

You are doing VoiceOver, I am asking for Voice Control


Applescript:


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


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#5 2021-03-15 03:30:06 pm

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Enable Voice Control

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?

Offline

 

#6 2021-03-15 10:44:06 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1797

Re: Enable Voice Control

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:

Applescript:


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"}

Applescript:


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"

Last edited by KniazidisR (2021-03-15 10:56:58 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#7 2021-03-16 04:00:33 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Enable Voice Control

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.

Offline

 

#8 2021-03-16 04:17:15 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1797

Re: Enable Voice Control

NMG wrote:

Where did you find that information?


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.

Last edited by KniazidisR (2021-03-16 04:19:42 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#9 2021-03-16 04:41:13 am

db123
Member
Registered: 2020-12-07
Posts: 16

Re: Enable Voice Control

NMG wrote:

Where did you find that information?


Applescript:


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

Last edited by db123 (2021-03-16 04:45:07 am)

Offline

 

#10 2021-03-16 04:46:11 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Enable Voice Control

KniazidisR wrote:

of group 1



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

Offline

 

#11 2021-03-16 04:52:47 am

db123
Member
Registered: 2020-12-07
Posts: 16

Re: Enable Voice Control

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.

Offline

 

#12 2021-03-16 05:43:22 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Enable Voice Control

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


That is very useful. Thank you!

Offline

 

#13 2021-03-16 05:51:42 am

db123
Member
Registered: 2020-12-07
Posts: 16

Re: Enable Voice Control

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.

Offline

 

#14 2021-04-13 02:41:27 am

NMG
Member
Registered: 2019-09-29
Posts: 54

Re: Enable Voice Control

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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)