Alright. I'm asking this to solely solve this one problem. I've got a shortcut assigned to change "Full Keyboard Access" setting inside "Keyboard" menu.
I need some way to track is it on or off. The only way I can think of is to count odd and even presses of hotkey issuing appropriate messages. I got a BitBar but don't how to utilise it.
If you want to track the change in the Tab key's behavior (though I'd argue it'll be evident the next time you press the button ;)) You'll probably need to count odds and evens, like you said. There's probably a dead simple way to do that in AppleScript etc.
I'm pretty sure that you can get the status (value) of the various System Prefs using a script. I think this would work much better than counting keystrokes.
Sorry, but I don't have the script at my fingertips. If @ccstone or someone doesn't come along soon to help, I'll try to find the script.
Meanwhile, you might try a google of "AppleScript system preferences"
Thanks, guys! @cfriend thanks for Macro. @JMichaelTX I’ll be much appreciated for a script!
I will investigate into Applescript more. One more question - how should I guess an option name in terms of OS? I saw some guides for changing options and they includes terminal commands with com.apple.SOMETHING. How did they get them?
Found somewhat “almost-there” solution. I can check current status of this option by typing in terminal:
defaults read -g AppleKeyboardUIMode
It will return 0 (off) or 2 (on) dependent of current setting.
Question is:
How can I track its status if KM reassign my defined shortcut (Hyperkey + F) to itself not allowing OS X shortcut (which is currently switching that thing happily)?
Is there a way to allow other hotkey to work and let KM just pass-by holding hands?
##Macro Library Get Status/Value of Full Access KB Preferences @Example
####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/b/b0f6618358b525b9403af51d4886ffcba1a8a93a.kmmacros">Get Status-Value of Full Access KB Preferences @Example.kmmacros</a> (12 KB)
---
###ReleaseNotes
Author.@JMichaelTX
PURPOSE:
* **Get the Status of the "All Controls" Radio Button on
System Preferences > Keyboard > Shortcuts > Full Keyboard Access**
* RETURNS "1" if the Button is ON; "0" if it is OFF.
HOW TO USE:
1. Trigger this macro from anywhere
(be sure to do "Macro Setup" first)
**MACRO SETUP**
* Assign a trigger
WHAT IT DOES:
* Uses the macOS System Events to perform UI scripting, and get value of the selected button.
USER SETTINGS:
* Any Action in magenta color is designed to be changed by end-user
ACTION COLOR CODES
* To facilitate the reading, customizing, and maintenance of this macro,
key Actions are colored as follows:
* GREEN -- Key Comments designed to highlight main sections of macro
* MAGENTA -- Actions designed to be customized by user
* YELLOW -- Primary Actions (usually the main purpose of the macro)
* ORANGE -- Actions that permanently destroy Varibles or Clipboards
REQUIRES:
(1) Keyboard Maestro Ver 7.2.1+
(2) Yosemite (10.10.5)+
---
<img src="/uploads/default/original/2X/4/4344c921caf110803dc2cd69b91b21040fe3f729.png" width="589" height="1001">
---
###AppleScript
```applescript
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
property ptyScriptName : "Determine if 'All Controls' is set for Full Access TAB Behavior"
property ptyScriptVer : "2.0"
property ptyScriptDate : "2017-03-24"
property ptyScriptAuthor : "JMichaelTX"
(*
PURPOSE: Get & Return Value of "Full Access" Radio button on
System Preferences > Keyboard > Shortcuts > Full Keyboard Access
RETURNS: "0" if OFF; "1" if ON.
KM VARIABLES REQUIRED: (must be set before calling this script)
• NONE
KM VARIABLES SET: (by this script)
• NONE
*)
property _CR : return
property _TAB : tab
--- TO BE RETURNED TO KM ---
-- Will be either actual results, or Error message
set scriptResults to "TBD"
try
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set frontApp to path to frontmost application as text -- use for dialogs
--- GET KM VARIABLE VALUES ---
--- GET NAME OF KB FULL ACCESS BUTTON TO CLICK --
-- MUST be "Text boxes and lists only" OR "All controls"
set buttonToCheck to "All controls"
with timeout of 10 seconds
tell application "System Preferences"
if not running then run # Works around 'activate' bug.
reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
activate
end tell
tell application "System Events"
tell process "System Preferences"
set frontmost to true
tell (first window whose subrole is "AXStandardWindow")
tell tab group 1
tell radio group 1
set rg1Elem to UI elements
--- GET UPDATED VALUES AFTER ABOVE CLICK ---
tell radio button buttonToCheck
set buttonValue to value of attribute "AXValue"
end tell
end tell -- radio group 1
end tell -- tab group 1
end tell -- window 1
end tell -- "System Preferences"
end tell -- "System Events"
--- Comment-out Next Statement if you want to see results ---
tell application "System Preferences" to close window 1
end timeout
set scriptResults to buttonValue
--~~~~~~~~~~~~~ END TRY ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
on error errMsg number errNum
if errNum = -128 then ## User Canceled
set errMsg to "[USER_CANCELED]"
else
-- Some other error, just use system errMsg
end if
set scriptResults to "[ERROR]" & return & errMsg & return & return ¬
& "SCRIPT: " & ptyScriptName & " Ver: " & ptyScriptVer & return ¬
& "Error Number: " & errNum
end try
--~~~~~~~~~~~~~~~~END ON ERROR ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- RETURN THE RESULTS TO THE KM EXECUTE SCRIPT ACTION ---
return scriptResults
(*
~~~ UI ELEMENT LIST DOWN TO RADIO BUTTONS ~~~
<AXApplication: “System Preferences”>
<AXWindow: “Keyboard”>
<AXTabGroup>
<AXRadioGroup>
<AXRadioButton: “Text boxes and lists only”>
Attributes:
AXEnabled: “1”
AXParent: “<AXRadioGroup>”
AXSize: “w=193 h=18”
AXFocused (W): “0”
AXRole: “AXRadioButton”
AXTopLevelUIElement: “<AXWindow: “Keyboard”>”
AXHelp: “(null)”
AXValue: “1”
AXPosition: “x=1394 y=530”
AXWindow: “<AXWindow: “Keyboard”>”
AXRoleDescription: “radio button”
AXTitle: “Text boxes and lists only”
AXFrame: “x=1394 y=530 w=193 h=18”
Actions:
AXPress - press
*)
```
I’m using Yosemite 10.10.5. If I am leaving script alone as it is, it doesn’t switch state properly. I mean, it doesn’t switch at all. I have inserted “Type A Keystroke” action to solve this.
The purpose of the script is NOT to change/switch the Full Access setting.
The purpose is just to report the current status of the "All Controls" choice.
Isn't this what you asked for:
If what you want is to set "All Controls" regardless of the current setting, I actually have another script that will do that.
For better readability it converts the result to text:
if it’s 0 it converts the variable to the text “Text boxes and lists only”
if it’s 2 it converts the variable to the text “All controls”
It displays the result text in a notification:
Of course, the actions in the macro are just examples of what you can do with the result of the shell script, and you can replace them with actions of your choice.
Actually, made Tom's conclusions myself right after download of your script, @JMichaelTX (Thanks @Tom btw ) Just wanted to appreciate your work, @JMichaelTX.
I'm start doing it for my TextExpander popup window (so I can use keyboard to select things I need. Which is TextExpander somehow misses)
Yes, I posted the macro because I had the impression that your main problem was that you didn’t know how to use the output of the shell script in KM. (Since you had already found the correct shell script.)