Automators 36: Sal Soghoian's Control Panel

For anyone it might, help, here’s the AppleScript for the Alfred (or any other) workflow:

set isRunning to application "System Preferences" is running

tell application "System Preferences"
	if not isRunning then launch
	reveal anchor "Keyboard" of pane id "com.apple.preference.universalaccess"
end tell
delay 0.5
tell application "System Events"
	tell application process "System Preferences"
		click radio button "Accessibility Keyboard" of tab group 1 of group 1 of window "Accessibility"
		set theCheckbox to checkbox "Enable Accessibility Keyboard" of tab group 1 of group 1 of window "Accessibility"
		set isChecked to value of theCheckbox
		click theCheckbox
		if isChecked is 1 then
			delay 0.5
			click button 1 of sheet 1 of window "Accessibility"
		end if
	end tell
end tell

There is an addition where I first get the current state of the accessibility keyboard, and then if it was enabled, clicking the checkbox disables it but ONLY after you respond to a confirmatory dialog box, which the extra code handles.

Now my “panel” workflow in Alfred works easily as a toggle.

If you want to post code to the forum, the best way to do it is to use a “code fence” which consists of three ` characters in a row on a line by themselves.

     Anything which is 
            inside the code fence 
     can be formatted 
            like this

If you only need one line to be code-formatted, just use a single ` at the beginning and ending of the command such as: sudo softwareupdate --list

HTH.

1 Like

FYI I updated your post to contain the formatting TJ suggested so you can see it in practise :slight_smile:

Greetings! When developing a panel, I put the “connection” scripts in the Home > Library > Scripts folder so they will be available for testing and editing from the system-wide Script menu, which is activated in the Script Editor application preferences. You can run the scripts from the menu, and if you hold down the Option key when selecting them from the menu, open them in the default script editor application (I use Script Debugger from LateNight Software). Cheers! https://latenightsw.com

2 Likes

The script you have open is a Script Library. You don’t “run” library scripts – you call them from other scripts. The error is saying that the script library links to another script library named DC-Keynote which apparently has not been installed.

1 Like

Here’s how to get the IDs of every system preference:

tell application "System Preferences"
	get the id of every pane
end tell

--> returns: {"com.apple.preference.universalaccess", "com.apple.preferences.Bluetooth", "com.apple.preference.datetime", "com.apple.preference.desktopscreeneffect", "com.apple.preference.displays", "com.apple.preference.dock", "com.apple.preference.energysaver", "com.apple.preferences.extensions", "com.apple.preference.general", "com.apple.preferences.icloud", "com.apple.preferences.internetaccounts", "com.apple.preference.keyboard", "com.apple.Localization", "com.apple.preference.expose", "com.apple.preference.mouse", "com.apple.preference.network", "com.apple.preference.notifications", "com.apple.preferences.parentalcontrols", "com.apple.preference.printfax", "com.apple.preferences.configurationprofiles", "com.apple.preference.security", "com.apple.preferences.sharing", "com.apple.preference.speech", "com.apple.preferences.softwareupdate", "com.apple.preference.sound", "com.apple.preference.spotlight", "com.apple.preference.startupdisk", "com.apple.prefs.backup", "com.apple.preferences.password", "com.apple.preference.trackpad", "com.apple.preferences.users", "com.apple.preferences.wallet"}```
2 Likes

@Tjluoma and @RosemaryOrchard: Thank you both for fixing up my code formatting. Appreciated, as well as the instructions on how to do it correctly in the future!

1 Like

Here’s how to get the anchor names from the currently showing system preference:

tell application "System Preferences"
	get the name of every anchor of the current pane
end tell

--> returns: {"Siri", "Keyboard", "Dwell", "Captioning", "Seeing_VoiceOver", "SpeakableItems", "TextToSpeech", "Hearing", "Switch", "General", "Media_Descriptions", "Mouse", "Seeing_Display", "Virtual_Keyboard", "Seeing_Zoom"}
3 Likes

@Sal: Thanks!

I actually opted to just create a folder for these scripts (located in my ResilioSync folder so I can work on both laptop and desktop) to contact the scripts. Since they are sucked into the panel bundle when you connect them to buttons, you can be free to experiment with these scripts and then reattach them anew if you make changes. It’s too bad the panel editor does not provide the facility for in-place editing and updating, but I guess I don’t want to get too greedy!

Another useful utility is UIBrowswer (https://pfiddlesoft.com/uibrowser/) which can be used to browse elements of the user interface to find out how to do things with UI scripting. I found the reference in the above-linked article from Federico. For $55 I will probably buy it. I don’t do UI scripting that often, or at least I didn’t until now, but I can see where this will be a big time saver. The Accessibilty Interface browser that comes with XCode does not provide the level of information needed to make this easy.

Here’s how to show the anchor for a specific pane:

tell application "System Preferences"
	activate
	set the current pane to pane id "com.apple.preference.universalaccess"
	reveal anchor "Virtual_Keyboard" of the current pane
end tell

Whatever works for you! UIBrowser from Bill Cheeseman is a must-have! Cheers.

Also, if it’s a bundle, be sure to check that the resource folder of the bundle doesn’t contain support items like applets or documents. Those would get lost if the change.

I’m still getting by with this old script:

http://hints.macworld.com/article.php?story=20111208191312748

:grinning:

The ol’ “entire contents” property. Thank you to John C. for putting that in the code.

I’m not generally stingy when it comes to buying software, but $100 for Script Debugger and $55 for UIBrowser are two that, as much as I’d like to have them, I don’t think I’d use them enough to justify the expense.

I’d put them on my Christmas list but my family already thinks I’m weird.

3 Likes

I know @dfay mentioned this, but I want to re-emphasize that Duet Display works quite well for this setup. It sounds like the Luna Display is a good option, but folks should realize there is a workable option that is markedly less expensive through use of the Duet app. — jay

3 Likes

I have the two scripts in the same folder. I put them here - Home > Library > Scripts

To be activated, Script Libraries are placed in Home > Library > Script Libraries

Cheerts

1 Like

Given I already have Duet - but hardly use it :see_no_evil: :joy: - this would be a VERY cheap option for me.

Meanwhile I have StreamDecks…

Followed all the steps in the videos, double-checked file locations and privacy settings, but still the keynote panel will not show up.

When I get into keynote and press the keyboard viewer I get the standard acc keyboard with an empty custom keyboard/panel (“none”)

The list of “special panels” when I click the gear icon is also empty even though the file is in the AssistivveControl directory.

Any ideas?