AppleScript is a scripting language created by Apple Inc. that facilitates automated control of Mac applications.
[4][5] AppleScript is primarily a mechanism for driving Apple events – an inter-application communication (IAC) technology that exchanges data between and controls applications.
AppleScript is tightly bound to the MacOS environment as are other command languages such as Unix shell, Windows Script Host and Rexx.
One way that AppleScript is bound to the unique aspects of its environment is that it relies on applications to publish dictionaries of addressable objects and operations.
Apple engineers recognized that a similar, but more object-oriented scripting language could be designed to be used with any application, and the AppleScript project was born as a spin-off of a research effort to modernize the Macintosh as a whole and finally became part of System 7.
This, in turn, led to AppleScript being widely adopted within the publishing and prepress world, often tying together complex workflows.
"[9] In October 2016, longtime AppleScript product manager and automation evangelist Sal Soghoian left Apple when his position was eliminated "for business reasons".
[11] Apple senior vice president of software engineering Craig Federighi responded in an email saying that "We have every intent to continue our support for the great automation technologies in macOS!
", though Jeff Gamet at The Mac Observer opined that it did little to assuage his doubt about the future of Apple automation in general and AppleScript in particular.
[5]: xxvi Apple events allow a script to work with multiple applications simultaneously, passing data between them so that complex tasks can be accomplished without human interaction.
[4] For example, an AppleScript to create a simple web gallery might do the following: For the user, hundreds or thousands of steps in multiple applications have been reduced to the single act of running the script, and the task is accomplished in much less time and with no possibility of random human error.
To designate which application is meant to be the target of such a message, AppleScript uses a "tell" construct: Alternatively, the tell may be expressed in one line by using an infinitive: For events in the "Core Suite" (activate, open, reopen, close, print, and quit), the application may be supplied as the direct object to transitive commands: The concept of an object hierarchy can be expressed using nested blocks: The concept of an object hierarchy can also be expressed using either nested prepositional phrases or a series of possessives: which in another programming language might be expressed as sequential method calls, like in this pseudocode: AppleScript includes syntax for ordinal counting, "the first paragraph", as well as cardinal, "paragraph one".
Some also provide for listing AppleScript dictionaries, saving scripts in a number of formats, syntax highlighting and inserting code snippets.
A framework for attaching Cocoa interfaces to AppleScript applications, part of the Xcode package in Mac OS X 10.4 and 10.5, now deprecated in favor of AppleScriptObjC.
[30]: 438 A Cocoa development software framework, also called AppleScript/Objective-C or ASOC,[31] part of the Xcode package since Mac OS X Snow Leopard.
[35] These background-only applications, packaged with macOS, are used to allow AppleScript to access features that would not normally be scriptable.
As of Mac OS X 10.6.3 they include the scriptable applications for: Plug-ins for AppleScript developed by Apple or third parties.
[36] They are designed to extend the built-in command set, expanding AppleScript's features and making it somewhat less dependent on functionality provided by applications.
macOS includes a collection of scripting additions referred to as Standard Additions (StandardAdditions.osax) that adds a set of commands and classes that are not part of AppleScript's core features, including user interaction dialogs, reading and writing files, file system commands, date functions, and text and mathematical operations; without this OSAX, AppleScript would have no capacity to perform many basic actions not directly provided by an application.
A script can define custom data types, or use one of the many built-in classes and objects which are provided by the language and tend to be recognized by scriptable applications.
Notable built-in types and objects include: AppleScript supports compound statement code structure via either single or multiple line syntax.
(The character, produced by typing ⌥ Option+return in the Script Editor, denotes continuation of a single statement across multiple lines.)
Each user interaction method can return the values of buttons clicked, items chosen or text entered for further processing.
Commands included as scripting additions are available system-wide, and are not dependent on an application (see also § AppleScript Libraries).
Under OS X Yosemite and later versions of macOS, the JavaScript for Automation (JXA) component remains the only serious OSA language alternative to AppleScript,[14] though the Macintosh versions of Perl, Python, Ruby, and Tcl all support native means of working with Apple events without being OSA components.