Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Two osascript hacks to inventory osx application object models, for osascripting them from shell scripts
#! /bin/sh
# lists all widgets of the app named $1 to stdout
# You will probably need to first add Terminal.app here (osx Yosemite; 10.10.3):
# System Preferences -> Security & Privacy -> Privacy -> Accessibility
osascript \
-e 'tell application "'$1'" to activate' \
-e 'tell application "System Events" to tell process "'$1'" to set output to entire contents of front window' \
| tr ',' '\n' \
| sed 's/^ *//'
#! /bin/sh
# lists all menu items of the app named $1 to stdout
# You will probably need to first add Terminal.app here (osx Yosemite; 10.10.3):
# System Preferences -> Security & Privacy -> Privacy -> Accessibility
osascript \
-e 'tell application "'$1'" to activate' \
-e 'tell application "System Events" to tell process "'$1'" to set output to entire contents of menu bar 1' \
| tr ',' '\n' \
| sed 's/^ *//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.