What can you tell applications to do using AppleScript?
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.



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