Apple Event Manager
Overview
The Apple Event Manager, a part of the Open Scripting Architecture (OSA), provides facilities for applications to send and respond to Apple events and to make their operations and data available to AppleScript scripts. For related API reference, see Open Scripting Architecture Reference.
An Apple event is a type of interprocess message that can specify complex operations and data. Apple events provide a data transport and event dispatching mechanism that can be used within a single application, between applications on the same computer, and between applications on different computers connected to a network.
Applications typically use Apple events to request services and information from other applications or to provide services and information in response to such requests. All applications that present a graphical interface to the user through the Human Interface Toolbox (Carbon applications) or the Cocoa application framework should be able to respond, if appropriate, to certain events sent by the Mac OS. These include the open application (or launch), reopen, open documents, print documents, and quit events.
Some Apple Event Manager functions are marked as being thread safe—for all other functions, you should call them only on the main thread.
For an overview of technologies that take advantage of the Apple Event Manager, see AppleScript Overview.
For information on working with Apple events, including events sent by the Mac OS, see Responding to Apple Events in Apple Events Programming Guide. For information about individual four-character codes used in Apple events, see AppleScript Terminology and Apple Event Codes Reference.
The Apple Event Manager is implemented by the AE framework, a subframework of the Core Services framework. You don’t link directly with the AE framework—instead, you typically link with the Carbon framework, which includes it. Some AppleEvent definitions are only available to clients of the Carbon framework, which includes, for example, AEInteraction.h in the HIToolbox framework.
The AE framework does not force a connection to the window server. This allows daemons and startup items that work with Apple events to continue working across log outs.
Gestalt Constants
You can check for version and feature availabilityinformation by using the Apple Event Manager selectors defined inthe Gestalt Manager. For more information see Inside macOS: Gestalt Manager Reference.
Topics
Adding Items to Descriptor Lists
Adding Parameters and Attributes to Apple Events and Apple Event Records
AEPutAttributeDesc(_:_:_:)AEPutAttributePtr(_:_:_:_:_:)AEPutParamDesc(_:_:_:)AEPutParamPtr(_:_:_:_:_:)
Coercing Descriptor Types
Counting the Items in Descriptor Lists
Creating an Apple Event
Creating and Duplicating Descriptors
Creating, Calling, and Deleting Universal Procedure Pointers
DisposeAECoerceDescUPP(_:)DisposeAECoercePtrUPP(_:)DisposeAEDisposeExternalUPP(_:)DisposeAEEventHandlerUPP(_:)DisposeOSLAccessorUPP(_:)DisposeOSLAdjustMarksUPP(_:)DisposeOSLCompareUPP(_:)DisposeOSLCountUPP(_:)DisposeOSLDisposeTokenUPP(_:)DisposeOSLGetErrDescUPP(_:)DisposeOSLGetMarkTokenUPP(_:)DisposeOSLMarkUPP(_:)InvokeAECoerceDescUPP(_:_:_:_:_:)InvokeAECoercePtrUPP(_:_:_:_:_:_:_:)InvokeAEDisposeExternalUPP(_:_:_:_:)InvokeAEEventHandlerUPP(_:_:_:_:)InvokeOSLAccessorUPP(_:_:_:_:_:_:_:_:)InvokeOSLAdjustMarksUPP(_:_:_:_:)InvokeOSLCompareUPP(_:_:_:_:_:)InvokeOSLCountUPP(_:_:_:_:_:)InvokeOSLDisposeTokenUPP(_:_:)InvokeOSLGetErrDescUPP(_:_:)InvokeOSLGetMarkTokenUPP(_:_:_:_:)InvokeOSLMarkUPP(_:_:_:_:)NewAECoerceDescUPP(_:)NewAECoercePtrUPP(_:)NewAEDisposeExternalUPP(_:)NewAEEventHandlerUPP(_:)NewOSLAccessorUPP(_:)NewOSLAdjustMarksUPP(_:)NewOSLCompareUPP(_:)NewOSLCountUPP(_:)NewOSLDisposeTokenUPP(_:)NewOSLGetErrDescUPP(_:)NewOSLGetMarkTokenUPP(_:)NewOSLMarkUPP(_:)
Creating Descriptor Lists and Apple Event Records
Creating Object Specifiers
CreateCompDescriptor(_:_:_:_:_:)CreateLogicalDescriptor(_:_:_:_:)CreateObjSpecifier(_:_:_:_:_:_:)CreateOffsetDescriptor(_:_:)CreateRangeDescriptor(_:_:_:_:)
Deallocating Memory for Descriptors
Deallocating Memory for Tokens
Deleting Descriptors
Getting, Calling, and Removing Object Accessor Functions
AECallObjectAccessor(_:_:_:_:_:_:)AEGetObjectAccessor(_:_:_:_:_:)AEInstallObjectAccessor(_:_:_:_:_:)AERemoveObjectAccessor(_:_:_:_:)
Getting Data or Descriptors From Apple Events and Apple Event Records
AEGetAttributeDesc(_:_:_:_:)AEGetAttributePtr(_:_:_:_:_:_:_:)AEGetParamDesc(_:_:_:_:)AEGetParamPtr(_:_:_:_:_:_:_:)
Getting Information About the Apple Event Manager
Getting Items From Descriptor Lists
Getting the Sizes and Descriptor Types of Descriptors
Initializing the Object Support Library
Locating Processes on Remote Computers
AECreateRemoteProcessResolver(_:_:)AEDisposeRemoteProcessResolver(_:)AERemoteProcessResolverGetProcesses(_:_:)AERemoteProcessResolverScheduleWithRunLoop(_:_:_:_:_:)
Managing Apple Event Dispatch Tables
Managing Coercion Handler Dispatch Tables
AEGetCoercionHandler(_:_:_:_:_:_:)AEInstallCoercionHandler(_:_:_:_:_:_:)AERemoveCoercionHandler(_:_:_:_:)
Managing Special Handler Dispatch Tables
Operating On Descriptor Data
Resolving Object Specifiers
Creating Apple Event Structures in Memory
AEPrintDescToHandle(_:_:)vAEBuildAppleEvent(_:_:_:_:_:_:_:_:_:_:_:)vAEBuildDesc(_:_:_:_:)vAEBuildParameters(_:_:_:_:)
Creating Apple Event Structures Using Streams
AEStreamClose(_:_:)AEStreamCloseDesc(_:)AEStreamCloseList(_:)AEStreamCloseRecord(_:)AEStreamCreateEvent(_:_:_:_:_:_:_:)AEStreamOpen()AEStreamOpenDesc(_:_:)AEStreamOpenEvent(_:)AEStreamOpenKeyDesc(_:_:_:)AEStreamOpenList(_:)AEStreamOpenRecord(_:_:)AEStreamOptionalParam(_:_:)AEStreamSetRecordType(_:_:)AEStreamWriteAEDesc(_:_:)AEStreamWriteData(_:_:_:)AEStreamWriteDesc(_:_:_:_:)AEStreamWriteKey(_:_:)AEStreamWriteKeyDesc(_:_:_:_:_:)
Working With Lower Level Apple Event Functions
Serializing Apple Event Data
Miscellaneous
Callbacks
AERemoteProcessResolverCallbackAEDisposeExternalProcPtrAECoerceDescProcPtrAECoercePtrProcPtrAEEventHandlerProcPtrOSLAccessorProcPtrOSLAdjustMarksProcPtrOSLCompareProcPtrOSLCountProcPtrOSLDisposeTokenProcPtrOSLGetErrDescProcPtrOSLGetMarkTokenProcPtrOSLMarkProcPtr
Data Types
AEArrayDataAEBuildErrorAEDescAEKeyDescAERemoteProcessResolverContextccntTokenRecordIntlTextOffsetArrayTextRangeTextRangeArrayTScriptingSizeResourceWritingCodeAEAddressDescAEArrayDataPointerAEArrayTypeAECoerceDescUPPAECoercePtrUPPAECoercionHandlerUPPAEDataStorageAEDataStorageTypeAEDescListAEEventSourceAEDisposeExternalUPPAEEventClassAEEventHandlerUPPAEEventIDAEKeywordAERecordAERemoteProcessResolverRefAEReturnIDAESendPriorityAEStreamRefAETransactionIDAppleEventDescTypeOffsetArrayHandleOSLAccessorUPPOSLAdjustMarksUPPOSLCompareUPPOSLCountUPPOSLDisposeTokenUPPOSLGetErrDescUPPOSLGetMarkTokenUPPOSLMarkUPP
Constants
AEBuildErrorCodeAESendModeApple Event Recording Event ID ConstantscAEListCallback Constants for the AEResolve FunctioncInsertionLoccKeystrokeComparison Operator ConstantsConstants for Object Specifiers, Positions, and Logical and Comparison OperationscURLcVersionData Array ConstantsDescriptor Type ConstantseSchemeEvent Class ConstantsEvent ID ConstantsEvent Source ConstantsFactoring ConstantsID Constants for the AECreateAppleEvent FunctionKey Form and Descriptor Type Object Specifier ConstantsKeyword Attribute ConstantsKeyword Parameter ConstantsLaunch Apple Event ConstantsNumeric Descriptor Type ConstantsObject Class ID ConstantsOther Descriptor Type ConstantsPriority Constants for the AESend Function (Deprecated in macOS)Remote Process Dictionary KeysSpecial Handler Callback ConstantsTimeout ConstantsWhose Test ConstantskAEDoObjectsExistkAEDebugPOSTHeaderkAEGetPrivilegeSelectionkAEHandleArraykAEInfokAEInternetSuitekAEISGetURLkAEISHTTPSearchArgskAELogOutkAEMenuClasskAEMouseClasskAENonmodifiablekAEQDNotOrkAESetPositionkAESocks4ProtocolkAEUseHTTPProxyAttrkAEUserTerminologykAEUseSocksAttrkAEUTHasReturningParamkAEZoomInkBySmallIconkConnSuitekeyAEAnglekeyAEBaseAddrkeyAEDoScalekeyAEHiliteRangekeyAEKeywordkeyAEPropDatakeyAESuiteIDkeyMenuIDkeyMiscellaneouskeyReplyPortAttrkeySOAPStructureMetaDatakeyUserNameAttrkFAServerAppkLaunchToGetTerminologykNextBodykOSIZDontOpenResourceFilekReadExtensionTermsMaskkSOAP1999SchemakTextServiceClasskTSMHiliteCaretPositionkTSMOutsideOfBodypArcAnglepFormulapNewElementLocpSchemepTextStylestypeAETexttypeApplicationBundleIDtypeFinderWindowtypeHIMenutypeKernelProcessIDtypeMachPorttypeMeterstypePixelMaptypeReplyPortAttrtypeTIFFtypeUnicodeText
Result Codes
noPortErrdestPortErrsessClosedErrerrAECoercionFailerrAEDescNotFounderrAECorruptDataerrAEWrongDataTypeerrAENotAEDescerrAEBadListItemerrAENewerVersionerrAENotAppleEventerrAEEventNotHandlederrAEReplyNotValiderrAEUnknownSendModeerrAEWaitCancelederrAETimeouterrAENoUserInteractionerrAENotASpecialFunctionerrAEParamMissederrAEUnknownAddressTypeerrAEHandlerNotFounderrAEReplyNotArrivederrAEIllegalIndexerrAEImpossibleRangeerrAEWrongNumberArgserrAEAccessorNotFounderrAENoSuchLogicalerrAEBadTestKeyerrAENoSuchObjecterrAENegativeCounterrAEEmptyListContainererrAEUnknownObjectTypeerrAERecordingIsAlreadyOnerrAEReceiveTerminateerrAEReceiveEscapeCurrenterrAEEventFilterederrAEDuplicateHandlererrAEStreamBadNestingerrAEStreamAlreadyConvertederrAEDescIsNullerrAEBuildSyntaxErrorerrAEBufferTooSmallerrASCantConsiderAndIgnoreerrASCantCompareMoreThan32kerrASTerminologyNestingTooDeeperrASIllegalFormalParametererrASParameterNotForEventerrASNoResultReturnederrAEEventFailederrAETypeErrorerrAEBadKeyFormerrAENotModifiableerrAEPrivilegeErrorerrAEReadDeniederrAEWriteDeniederrAEIndexTooLargeerrAENotAnElementerrAECantSupplyTypeerrAECantHandleClasserrAEInTransactionerrAENoSuchTransactionerrAENoUserSelectionerrAENotASingleObjecterrAECantUndoerrAENotAnEnumMembererrAECantPutThatThereerrAEPropertiesClash