Shortcut to a specific accessibility feature
Is it possible to apply a keyboard shortcut to toggle on/off a specific accessibility feature of Mac OS X, for instance the Switch Control or the Head Pointer?
Solution 1:
For Switch Control, see my answer to: applescript access switch control through system preferences
For Head Pointer:
How is it possible to check the box you mentioned for Head Pointer?
Quoted question from comment under the OP.
Test this example AppleScript code in Script Editor to see if it works. Then try it again with the activate
command commented out. e.g.: # activate
It may only work with System Preferences being visible, you'll just have to see.
if running of application "System Preferences" then
try
tell application "System Preferences" to quit
on error
do shell script "killall 'System Preferences'"
end try
delay 0.1
end if
repeat while running of application "System Preferences" is true
delay 0.1
end repeat
tell application "System Preferences"
activate
reveal anchor "Head_Pointer" of ¬
pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events"
tell application process "System Preferences"
repeat until (checkbox "Enable head pointer" of ¬
tab group 1 of group 1 of window 1 exists)
delay 0.1
end repeat
click checkbox "Enable head pointer" of ¬
tab group 1 of group 1 of window 1
delay 0.1
end tell
end tell
tell application "System Preferences" to quit
Notes:
The example AppleScript code can be use in a Automator Service/Quick Action and assigned a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services
Or there are several third party applications that can trigger AppleScript scripts, with assigned keyboard shortcuts , e.g. FastScripts.
Note that I am not affiliated with the developer of FastScripts, just a satisfied user.
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5
, with the value of the delay set appropriately.