AppleScript Programming/Scripting other applications

From Wikibooks, open books for an open world
Jump to: navigation, search

AppleScript can be used with other applications using the "tell" command. For example:

 tell application "Safari"

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

tell application "Safari"
   activate
end tell

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

You can also shorten the command above to simply this:

tell application "Safari" to activate
Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export