AppleScript Programming/Scripting other applications

AppleScript can be used with other applications using the "tell" command. The tell command means to send a message to an application.

Anything written under that will be executed in the application Safari. So if we wanted to tell Safari to activate, we'd type:

The "end tell" command will let AppleScript know that it has reached the end of the command. Also, make sure that the name of the application is in "quotes".

You can also shorten the command above to simply this:

Of course what Safari is for is getting content off of the web. The following example code activates Safari and has it open a particular web page.

Or instead of telling Safari to open a location, we could tell the Finder to and instead of our script specifying that Safari be run, the Finder would pick the default web browser and run that instead.

Notice that in the example above, we did not tell the Finder to activate. This means that the Finder didn't need to become the frontmost application. It just needed to be running, which is always is, and open the default web browser, which could be Firefox.app which doesn't even support AppleEvents. The Finder processed the tell-message and did the required action.

One thing that AppleScript is good at—why it was developed—is to combine the functionality of different Mac applications and let the user make new software without "reinventing the wheel"

Application Numbers
In the script below a range of cell values are read from the variable myTable which contains a reference to a table in an active document. It reads the values horizontally within the range, according to the reading direction of the language.