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
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
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.
@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!
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"}
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
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 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.
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