Important: The information in this document is obsolete and should not be used for new development.
Creating and Sending Apple Events
Your application can use Apple events to request services or information from other applications, send information to other applications, or trigger actions within your application. For example, you can use the core Apple event Get Data to request specific data from another application's documents. Similarly, you can use other Apple events to request services--for example, asking a spell-checking application to check the text in a document created by your application. Consult the Apple Event Registry: Standard Suites for the format and function of the standard Apple events that you want your application to send.To communicate with another application by sending an Apple event, your application must
The sections that follow describe how your application can use the Apple Event Manager to accomplish these tasks. The chapter "Creating and Sending Apple Events" in this book provides detailed information about creating and sending Apple events.
- set the appropriate flags in its
'SIZE'
resource- create an Apple event record by calling the
AECreateAppleEvent
function- use Apple Event Manager functions to add parameters and any additional attributes to the Apple event
- call the
AESend
function to send the Apple event- dispose of any copies of descriptor records that you have created
- handle the reply Apple event (if necessary)
To act as a server for your application, the target application must support high-level events and must be running. The server can be your own application, another application running on the user's computer, or an application running on another user's computer connected to the network.
Your application should also allow the user to choose among the various applications available as servers. The
PPCBrowser
function allows users to select target applications on their own computers or on computers connected to the network. ThePPCBrowser
function presents a standard user interface for choosing a target application, much as the Standard File Package provides a standard user interface for opening and saving files. See the chapter "Program-to-Program Communications Toolbox" in this book for details on using thePPCBrowser
function.If the server application is on a remote computer on a network, the user of that computer must allow program linking to the server application. The user of the server application does this by selecting the application icon in the Finder, choosing Sharing from the File menu, then clicking the Allow Remote Program Linking checkbox. If the user has not yet started program linking, the Sharing command offers to display the Sharing Setup control panel so that the user can start program linking. The user must also authorize remote users for program linking by using the Users & Groups control panel. Program linking and setting up authenticated sessions are described in the chapter "Program-to-Program Communications Toolbox" in this book.
Subtopics
- Creating an Apple Event Record
- Adding Apple Event Attributes and Parameters
- Sending an Apple Event and Handling the Reply