Apple Events Programming Guide
PDF
Introduction
About Apple Events
A Quick Look at Working With Apple Events
When Applications Use Apple Events
Apple Event Terminology
Sending and Receiving Apple Events
Responding to Apple Events
How to Use Apple Events
Steps for Responding to Apple Events
Steps for Creating and Sending Apple Events
Framework and Language Support
Building an Apple Event
About Apple Event Data Structures
Apple Event Building Blocks
Apple Event Constants
Event Class and Event ID
Descriptors, Descriptor Lists, and Apple Events
Apple Event Attributes and Parameters
Apple Event Attributes
Apple Event Parameters
Accessing Attributes and Parameters
Optional Parameters
Two Approaches to Creating an Apple Event
Creating an Apple Event in One Step
Creating an Apple Event Sequentially
The Completed Apple Event
Apple Event Dispatching
How Apple Event Dispatching Works
Dispatch Tables
The System Dispatch Table
Dispatching Apple Events in Your Application
Determining Which Apple Events to Respond To
Installing Apple Event Handlers
Processing Apple Events
Processing Apple Events With the Carbon Event Model
Processing Apple Events With WaitNextEvent
Working With the Data in an Apple Event
About Extracting Data From an Apple Event
Coercing Data From an Apple Event
Getting Data From an Apple Event Parameter
Getting Data From an Apple Event Attribute
Getting Data From a Descriptor
Getting Data From a Descriptor List
Disposing of Apple Event Data Structures
Responding to Apple Events
About Apple Event Handlers
Definition of an Apple Event Handler
Interacting With the User
Writing an Apple Event Handler
Extracting Information From the Apple Event
Performing the Requested Action
Adding Information to a Reply Apple Event
Returning a Result Code
Returning Error Information
A Handler for the Open Documents Apple Event
Handling Apple Events Sent by the Mac OS
Common Apple Events Sent by the Mac OS
Installing Handlers for Apple Events Sent by the Mac OS
Creating and Sending Apple Events
Functions for Creating Apple Event Data Structures
Specifying a Target Address
Creating a Target Address Descriptor
Addressing an Apple Event for Direct Dispatching
Obtaining the Addresses of Remote Processes
Creating an Apple Event
Creating an Apple Event With AEBuildAppleEvent
Creating an Apple Event With AECreateAppleEvent
Disposing of Apple Events You Create
Sending an Apple Event
When to Use AESend
When to Use AESendMessage
Specifying Send and Reply Options
Specifying a Reply in the Send Mode Parameter
Specifying User Interaction in the Send Mode Parameter
Sending an Apple Event With AESend
Sending an Apple Event With AESendMessage
Handling a Reply Apple Event
Writing and Installing Coercion Handlers
How Coercion Handlers are Installed and Dispatched
Writing a Coercion Handler
Installing a Coercion Handler
Testing a Coercion Handler
Testing and Debugging Apple Event Code
Determining If an Application Is Receiving Apple Events
Script Editor is an Apple Event Test Tool
Examining Apple Events
Turning on Apple Event Logging
Observing Apple Events for Multiple Applications
Setting Breakpoints and Printing Apple Events in GDB
Third Party Options
Appendix A: Selected Apple Event Manager Functions
Functions for Working With Apple Event Data Structures
Appendix B: Selected Apple Event Constants
Event Class Constants
Event ID Constants for Apple Events Sent by the Mac OS
Event ID Constants for Standard AppleScript Commands
Descriptor Type Constants
Address Descriptor Type Constants
Attribute Keyword Constants
Parameter Keyword Constants
Event Source Constants
Send Mode Constants for the AESend Function
Appendix C: Default Coercion Handlers
Coercion Handler Tables
Revision History