Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution 2.5 license, and examples are licensed under the BSD License. Edit this page
For Developers > Design Documents >
AppleScript is a widely used scripting language on Mac OS X, used for inter-process communication (IPC). It enables end-users who have no programming skills to easily create workflows and perform repetitive tasks. Supporting AppleScript also provides a consistent interface for communication with other applications.
If you are unfamiliar with AppleScript, you can read more about it at AppleScript Language Guide.
For implementation of AppleScript in your application, you might want to look at Cocoa Scripting Guide.
- SDEF - scripting definition file, contains all the classes, properties, commands that scripters can use.
- Automator - an application bundled with Mac OS X allowing the user to graphically build workflows on top of AppleScript.
AppleScript support involves five classes, each representing the classes defined in the sdef file:
ApplicationApplescript
- Not a separate class but a set of methods added in a category of BrowserCrApplication
- The name, frontmost, and version properties are all obtained by work done in NSApplication
- An application has windows as its elements
- The windows are obtained by traversing through BrowserList, wrapping each Browser in a WindowApplescript class and returning it as an NSArray
- A new window is created by creating a new Browser with a single blank tab
- A window is closed by calling browser->window()->Close()
- Bookmarks are represented as two folders elements, corresponding to the bookmarks bar and the "Other Bookmarks" folder
- Encapsulates a Browser object
- ID of a browser is obtained via browser->session_id().id()
- mode indicates whether a browser window is a normal or an incognito window. The mode is set only during creation and cannot be changed at a later time. The default is a normal window.