|
Getting Started with Scripting & AutomationTechnology OverviewMac OS X supports scripting languages that include AppleScript, JavaScript, Perl, PHP, Ruby, Python, and various shell script dialects. To move beyond the standard features of these languages, Mac OS X provides programming interfaces so that developers can make their applications user scriptable (or OSA compliant). This allows you, for example, to use AppleScript, a native Mac OS X scripting language, to write scripts that combine features from Mac OS X Finder, Apple applications such as Mail, iTunes, and QuickTime Player, and scriptable third-party applications such as web, database, and spreadsheet products. By integrating scripting support with many Apple technologies, Mac OS X can help you automate tasks ranging from system administration, to web content creation, to implementation of complex multiapplication workflows. Scripting environments that are bridged to the Mac OS X Objective-C runtime (including Ruby, through RubyCocoa, Python, through PyObjC, and AppleScript, through AppleScript Studio) can access Objective-C frameworks, including Apple’s Cocoa framework. Through the technology of framework metadata, these bridges can also provide access to functions and data types in most C-language frameworks. Other Apple and open source software bridges make it easier to take advantage of features offered by scriptable applications. For example, Scripting Bridge—available starting in Mac OS X version 10.5 (Leopard)—allows Cocoa applications or other Objective-C code to efficiently access scriptable applications using native Objective-C syntax. Scripting languages such as Ruby and Python can also use Scripting Bridge in Leopard; in addition, they have their own open source bridges (RubyOSA and py-appscript) to scriptable applications running in Leopard or Tiger. Mac OS X provides the Web Kit, which is used by Safari and Dashboard to render web content and widgets. To develop an interactive website or widget, you use JavaScript, Web Kit DOM APIs, and in the case of widgets, Dashboard-specific JavaScript APIs. In addition, several technologies, including Installer, Quartz Composer, and iSync Plug-in Maker, provide scripting environments that use JavaScript. Beyond standard scripting languages, Apple’s Automator application offers a drag-and-drop process for selecting and connecting individual operations, known as actions. Automator includes many actions that target Mac OS X and popular Apple applications, so users can automate a wide variety of tasks. Using Xcode templates, developers can create actions that make features from their applications available to Automator users. Start HereBefore you begin to use scripting on Mac OS X, you should read:
Choose a Learning PathThe uses for scripting and automation in Mac OS X are as varied as the goals and inventiveness of the developers who use them. The following are guidelines for performing some common tasks. Automation with AutomatorDevelopers, system administrators, and other Mac users can use Automator to automate repetitive tasks for themselves and their clients. For introductory tips, sample actions, and links to additional Automator resources, see Automator Resources. Development with AutomatorDevelopers can use Xcode to build actions that allow Automator users to access key features of their applications. Starting in Mac OS X version 10.5, you can also embed and execute Automator workflows in an application.
Automation and Development with AppleScriptSee Getting Started with AppleScript for detailed descriptions of the following learning paths:
Using Ruby and Python with Mac OS X FrameworksYou have several options for accessing Mac OS X frameworks from Ruby and Python:
Accessing Scriptable Applications with Scripting BridgeYou can access scriptable languages from Cocoa applications (or other Objective-C code) and from scripting languages such as Ruby and Python.
Scripting for System AdministratorsShell scripts are a fundamental part of the Mac OS X programming environment, and they can be particularly useful for system administrators. See Shell Scripting Primer to jump start your shell script development. In addition, you can execute shell scripts both with AppleScript scripts and with Automator actions. For information on the former, see “Scripting With AppleScript” in AppleScript Overview. For the latter, see “Creating Shell Script Actions” in Automator Programming Guide. Web Content and Dashboard Widget Development with JavaScript and Web Kit DOM
Scripting with QuickTimeFor information on how to automate and control browser operations with QuickTime and how to script operations with QuickTime Player, see QuickTime Scripting. Application Scripting with JavaScriptYou can use JavaScript in various Mac OS X technologies.
Creating an AppleScript Studio ApplicationYou can use AppleScript Studio to quickly create applications with complex user interfaces. For details, see the learning paths in Getting Started with AppleScript. Next StepsScripting & Automation Reference Library includes the following high-level resource pages, which you can bookmark for easy access:
For mailing lists where users and developers can share experiences, questions, and comments with other interested parties on technologies described in this document:
|
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)
|