|
Getting Started with AppleScriptTechnology OverviewAppleScript is a scripting language that provides convenient control of applications and of many parts of the Mac OS. AppleScript, which uses an English-like syntax, is a rich, object-oriented language. You can use it to automate simple tasks or implement complex workflows that combine operations from applications and the Mac OS. AppleScript uses a type of message called an Apple event for the underlying interprocess communication between scripts and applications. Most applications must be able to respond to Apple events because the Mac OS uses Apple events for certain basic actions, such as launching an application and providing a list of documents for it to open. A scriptable application is one that goes beyond the basics to make its data and operations available to AppleScript scripts or other applications. Scriptable applications are popular because users can write scripts to combine the capabilities of multiple applications. Making your application scriptable can also provide benefits in areas such as rapid development and automated testing. Both Carbon and Cocoa applications can be made scriptable, and the Cocoa framework contains built-in support that minimizes the amount of code you have to write. AppleScript provides limited support for displaying user-interface items from scripts. However, with AppleScript Studio, you can create Mac OS X applications that use AppleScript scripts to control complex user interfaces. That makes it a useful tool for system administrators or others who need to quickly automate a process while providing a full user interface. It can also be useful for rapid user-interface prototyping. The Automator application, available starting in Mac OS X version 10.4, provides a graphical interface for combining individual actions to create an automated workflow. Each action performs a distinct operation, such as copying a file, cropping a photo, or sending an email message. Automator includes actions that work with the Finder, Mail, iTunes, and other Apple applications, and you can write actions for key features of your applications. Starting in Mac OS X version 10.5, you can also use workflows in your applications. Starting in Mac OS X v10.5 (Leopard), the Scripting Bridge technology provides an automated process for creating an Objective-C interface to scriptable applications. This allows Cocoa applications or other Objective-C code to efficiently access features of scriptable applications, using native Objective-C syntax. Scripting languages such as Ruby and Python can also use the Scripting Bridge. (In addition, they have open source bridges—RubyOSA and py-appscript—to scriptable applications running in Leopard or Tiger.) For more information, see Getting Started With Scripting & Automation. AppleScript 2.0, which ships starting in Mac OS X v10.5, includes full support for Unicode text, additional support for identifying and working with application objects in scripts, 64-bit support, and more accurate and useful error messages. Mac OS X v10.5 also provides additional scriptability in Apple technologies such as iChat and the Dock. Start HereTo get a quick introduction to the basics of AppleScript:
To keep up with the latest developments in AppleScript, including news, recent articles, and additional resources, visit the AppleScript website and the AppleScript topic page. Choose a Learning PathWhatever your goal with AppleScript, you’ll want to read about the AppleScript language and learn how to use it to write scripts. If you’re an application developer, you’ll need additional information to write scriptable applications and to write Automator actions so that users can take full advantage of your applications in their Automator workflows. Writing AppleScript Scripts
Making Your Application ScriptableYou can support scripting in your application whether you develop in procedural C, C++, or Objective-C.
Using Automator in Your Application DevelopmentTo learn how to work with Automator, see the learning paths in “Development with Automator” in Getting Started With Scripting & Automation. Creating an AppleScript Studio ApplicationYou can use AppleScript Studio to quickly create applications with complex user interfaces that adhere to the guidelines in Apple Human Interface Guidelines.
Next StepsThe AppleScript Reference Library includes the following high-level resource pages, which can be bookmarked for easy access:
|
© 2004, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)
|