Skip to content

Instantly share code, notes, and snippets.

@johan
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johan/753f0830a92c34d5042a to your computer and use it in GitHub Desktop.
Save johan/753f0830a92c34d5042a to your computer and use it in GitHub Desktop.
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