Going bananas try to create macro to quickly access (turn on/off) features deep inside System Preferences

Hello,

I am constantly accessing System Preferences → Accessibility → scroll down on the left sided panel and click on the Keyboard → Accessibility Keyboard 'tab' on the right to either

  • check and uncheck Enable Accessibility Keyboard
  • click on the Panel Editor button

1- System Preferences → Accessibility is easy with the System Pref action

2- I can do the following by using the mouse click action relative to the front window corner - check and uncheck Enable Accessibility Keyboard - click on the Panel Editor button

The reason for doing so is to convert and configure an iPad to a KBM hard palette with the Luna display as explained below. At first I thought that an iPad hard palette would be a superfluous addition to the KBM palettes, but it turns out that the iPad hard palette is very efficient in terms of workflow.

I tried to solve the problem using UI Browser as previously suggested by @ccstone and @JMichaelTX, but gave up for the sake of preserving my sanity.

thanks in advance for your time and help

UI browser

Luna Display

Note that step 2 involves 2 sub steps: scrolling down the left panel and click on the keyboard

Have a look at this post:

So something like that should do (works for mojave+):
Toggle Accessibility Keyboard.kmmacros (16.7 KB)
(Original Script by user3439894 )
Probably not the best solution, as it takes a few seconds to execute. There are a lot of 'delays' in the script, you can try if it still works for you if you reduce them a bit.

1 Like

Ha, I think I found the same post as Julian. Here’s the AppleScript that worked for me:

tell application "System Preferences"
	reveal pane id "com.apple.preference.universalaccess"
	delay 1
	tell application "System Events"
		tell window 1 of application process "System Preferences"
			select table 1 of scroll area 1
			delay 0.1
			select row 17 of table 1 of scroll area 1
			delay 0.1
			tell tab group 1 of group 1
				click radio button "Accessibility Keyboard"
				delay 0.1
				click button "Panel Editor…"
			end tell
		end tell
	end tell
	-- quit
end tell

You can remove the -- in front of quit when you confirm that it is working. That will quit System Preferences when it is done.

2 Likes

@tjluoma @Julian_Steinmann

thank you both very much.

Works perfectly.

I have 2 follow up questions and I will leave you in peace:

1- as per the illustration below, I would like to modify the script to press on the Panel Editor button. I tried editing the script, but then nothing happens

2- I am trying to decipher Applescripts which access different areas of Mojave Sys Pref and would like to start by understanding what pane, table, scroll area 1 or or ..., checkbox 1,2 etc, windows, tab groups, the numbering system etc refer to in the sequential sys pref panes..

I would imagine that some annotated illustration must exist but I can't find it with google.

thanks again very much

This is my failed attempt to modify your scripts:

Someone, I think maybe Jason Snell, commented that almost no one writes AppleScript. We just copy/paste things together until it works.

You should not need to add anything to the AppleScript that I sent.

When I tested it, it was successfully clicking the "Panel Editor…" button. If that is not working for you, it might be because I wrote it on Mojave if you using Catalina, or it might be that you need to increase the delays, especially the '0.1' delays. Change them to '1' and see if it works, then try reducing them to see how low you can go and still have it work reliably.

I'll decipher the AppleScript as best as I understand it:

tell application "System Preferences"
	reveal pane id "com.apple.preference.universalaccess"

This will launch System Preferences and open the 'Accessibility' pane.

	delay 1
	tell application "System Events"
		tell window 1 of application process "System Preferences"
			select table 1 of scroll area 1

This says "Wait 1 second, then tell the system to select the left column" (table 1 of scroll area 1).

			delay 0.1
			select row 17 of table 1 of scroll area 1

row 17 = "Keyboard".

Now, if you select the first item in that left column (General) and then count as you press the "down arrow", you will only get the "12" when you arrive at "Keyboard". So why is it "17" here? Because each of the "headers" (General, Vision, Media, Hearing, Interaction) above "Keyboard" also counts as a row.

How did I figure that out? I put in 12 and it select the wrong thing, so I kept increasing it until I got the right one.

			delay 0.1
			tell tab group 1 of group 1
				click radio button "Accessibility Keyboard"

This clicks the "button" named "Accessibility Keyboard" (#4 in your original image)

				delay 0.1
				click button "Panel Editor…"

This should click the "Panel Editor…" button. Note that is an actual ellipsis not three periods.

			end tell
		end tell
	end tell
	-- quit
end tell

All of those 'end tell' lines just close off their corresponding 'tell' lines above.

The 'quit' line (if it did not have the '--' in front of it) would tell System Preferences.app to quit.

(In the part you added, it appears that you were trying to click a button named "OK" which does not exist.)

However…

Now that I have paid more attention to what is going on, I realize that the "Panel Editor…" button is just launching an app, which means we don't need to do any of this.

You can just do this (in AppleScript):

tell application "Panel Editor" to activate

or this (in a shell script)

open -a 'Panel Editor'

You could also do:

open -b com.apple.AssistiveControl.editor

but now I'm just being fancy :wink:

3 Likes

extremely interesting and instructive.
I can't thank you enough !.
You mentioned in an earlier post that you were very busy. I apologize for taking so much of your time.
I also make a good mental note of your words of wisdom concerning appleScript writing.

While I have certainly used/modified many AppleScripts written by others, I will have to disagree with that overstatement of "almost no one".

I would say that many, perhaps most, Mac users don't know how to write AppleScripts, or any other kind of script. :wink:

But maybe Swift is changing that, particularly among new young users. We'll have to see.

1 Like

Please don’t worry about it. If I was too busy to be here, or too busy to help, then I wouldn’t be. You did not take any time that I did not freely offer.

I was stuck at home today as workers tore up carpeting and drywall downstairs (long story), so this helped me pass the time, and I also really enjoy figuring this stuff out. I have also found that many of the things I have learned to help someone else often ends up benefiting me too, somewhere down the road.

1 Like