1

I know that you can use the tell application "" command in AppleScript to do many simple things like open a website in Google Chrome, play and iTunes song, or do keystrokes with System Events. Are there any other things that you can tell applications to do that might come in handy in some way? (I already know the iTunes and Finder tells... please don't include those).

  • Earlier, I used to use some sort of Applescript Editor feature where you could explore all of an application's tells. Trying to look for it now – TheBro21 Apr 8 '16 at 19:17
7

There is a feature in the Applescript editor called the Library. it can be accessed through Window > Library on the top navbar, or with the shortcut Shift+Command+L. You can double click on the applications there, and you will see all functions, variables, etc.

enter image description here

The windows looks like this. Double clicking shows a new window with all possible functions, vars, etc for Applescript, and even Javascript and Objective-C. You can select those in a dropdown.

Data Types

In the window explaining possible actions, you will see a tag and an icon next to it. The icons represent the type. S stands for Suite, E stands for element, blue C stands for Class, purple C stands for class or collection, and purple P stands for property.

Say we have this example:

tell application "Safari"
set a to URL of current tab of first window
end tell

URL is a property of the type tab, current tab is also a property, but of the window. This is one way to use classes. The other way would be something like:

open n From the standard suite, this would open the object n.

AFAIK, Suites and elements do not have special treatment in Applescript


as @user3439894 mentioned in the comment section: If the application you are looking for is not in the library, you can open it's dictionary with Shift+Command+O, and selecting the app.


There is also a search for a certain keyword.

Let's say we want to learn how to use System Events to do press a key. If we search, we see that there is something called keystroke in the Processes Suite, and shows a description of:

keystroke v : cause the target process to behave as if keystrokes were entered
keystroke text : The keystrokes to be sent.
[using command down/‌control down/‌option down/‌shift down or list of command down/‌control down/‌option down/‌shift down] : modifiers with which the keystrokes are to be entered
  • One can also use the File > Open Dictionary... ⇧⌘O, command to access other Application's Dictionaries that are not already in the Library, even though they can also be added via the Library nonetheless the Open Dictionary... command gives a list, whereas adding to from the Library one has to navigate to the Application bundle to add it. – user3439894 Apr 8 '16 at 19:47
  • This could be its own question, but it would fit in your answer: Where are the relationships between S, E, C, C and P defined and described? – Wildcard Apr 9 '16 at 0:20
  • 1
    @Wildcard I guess I kind of relied on the user to figure out. I will edit that in tomorrow – TheBro21 Apr 9 '16 at 0:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .