Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there some canonical place I can find a reference for the scripting capabilities various things have in AppleScript?

For instance, I'd like to automate iTunes a little bit. Looking around on the web I see iTunes supports get album of current track and current track has several properties: name, artist, etc. But nowhere can I find a reference for all of iTunes' properties, or capabilities other than current track. That info may be on Doug's AppleScripts for iTunes somewhere, but then that's iTunes specific, I want a general reference for all apps.

Similarly, Google Chrome has some scriptability. How can I discover what it can do? It's a third party product and Google has written some of their own docs, but they seem incomplete.

A website AppleScript reference would be great. Even better would be if AppleScript has some introspection abilities so I can just ask iTunes itself what it supports with AppleScript code. (Honestly I hate the language, but it seems to be the only way to access a lot of neat things in MacOS apps.)

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Most apps that can be scripted with AppleScript will have a dictionary you can open with AppleScript Editor (File > Open Dictionary). The app's dictionary will then list details for each of the commands and classes that can be used with it in an AppleScript script.

Creating an AppleScript dictionary is up to the app's developer, so you may occasionally come across apps with poorly documented, incomplete or outdated dictionaries, but it's still usually a good place to start.

share|improve this answer
1  
+1 just to add to joelseph's answer - dictionaries are the best place to start on a per application basis, but you should really read something like Rosenthal's AppleScript book to actually understand how AppleScript works to get the most power out of the language. –  Stu Wilson Feb 11 '12 at 21:30

You could open the application's dictionary in AppleScript Editor from the ⇧⌘O dialog.

A few basic commands for examining objects:

tell application "Finder"
    properties
    properties of window 1
end tell

tell application "System Events" to tell process "Finder"
    UI elements
    {name, value} of attributes of some UI element
end tell
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.