Hey Folks,
Many things on macOS cannot be scripted directly due to a lack of scripting support.
Keyboard Maestro is wonderful tool for automating such things, but sometimes it needs a little help to do its job better.
Enter UI-Scripting which provides access to the accessibility API of macOS through the System Events application.
Here’s an example of UI-Scripting you can run with the Script Editor.app:
tell application "System Events"
tell application process "Dock"
tell list 1
tell UI element "Safari"
perform action "AXShowMenu"
set diagnosticsList to {¬
"----- PROPERTIES -----", ¬
properties, ¬
"----- UI ELEMENTS -----", ¬
UI elements, ¬
"----- ATTRIBUTES -----", ¬
attributes, ¬
"----- ACTIONS -----", ¬
actions, ¬
"----- END -----"}
end tell
end tell
end tell
end tell
** Safari needs to be running!
The script will open Safari’s Dock menu and then provide some diagnostic information for the UI-Element where the diagnostic code is located.
I cheated and used PFiddlesoft’s UI Browser utility to acquire the initial Safari Dock item and then I used my diagnostic construct to move down the tree to where it is now.
----- More to come -----
-Chris