Apple events are the message-based interprocess communication mechanism in Mac OS , first making an appearance in System 7 and supported by every version of the classic Mac OS since then and by macOS . Apple events describe "high-level" events such as "open document" or "print file", whereas earlier OSs had supported much more basic events, namely "click" and "keypress". Apple events form the basis of the Mac OS scripting system, the Open Scripting Architecture (the primary language of such being AppleScript ).
58-657: The starting point is a dynamically-typed, extensible descriptor format called an AEDesc , which is just an OSType code specifying the data type, together with a block of type-dependent data. For instance, the OSType code inte indicates that the data was a four-byte signed integer in big-endian format. Besides predefined type codes for various common simple types, there are two predefined structured descriptor types: an AERecord , which has data type reco (record), and AEList with type list (list or array). The internal structure of these contain recursively-nested AEDescs, while
116-552: A Uniform Type Identifier and are no longer used as the primary data type signature. Mac OS X (macOS) prefers the more colloquial convention of labelling file types using file name extensions. At the time of the change, the change was a source of great contention among older users, who believed that Apple was reverting to a more primitive way that misplaces metadata in the filename. Filesystem-associated type codes are not readily accessible for users to manipulate, although they can be viewed and changed with certain software, most notably
174-680: A child of that parent, all collected in an AERecord . An iterator was provided by parents to enumerate their children, or children of a certain class, allowing applications to address a set of elements. The system was generally similar to the Document Object Model used in XML , although with some differences in access patterns. Each object could have elements and properties ; elements were other objects, which might be created or deleted, while properties could not be created or deleted but had values which might be interrogated or changed. For instance,
232-572: A child of that parent, all collected in an AERecord . An iterator was provided by parents to enumerate their children, or children of a certain class, allowing applications to address a set of elements. The system was generally similar to the Document Object Model used in XML , although with some differences in access patterns. Each object could have elements and properties ; elements were other objects, which might be created or deleted, while properties could not be created or deleted but had values which might be interrogated or changed. For instance,
290-476: A human-readable way (e.g., " mp4a "). Some FourCCs however, do contain non-printable characters, and are not human-readable without special formatting for display; for example, 10bit Y'CbCr 4:2:2 video can have a FourCC of ('Y', '3', 10, 10) which ffmpeg displays as rawvideo (Y3[10] [10] / 0x0A0A3359), yuv422p10le . Four-byte identifiers are useful because they can be made up of four human-readable characters with mnemonic qualities, while still fitting in
348-410: A process on the local or a remote machine), and various other options for handling it. Remote machines initially had to be connected via AppleTalk , but Mac OS 9 added the option for connections via TCP/IP . After sending an Apple event to its target process, the sending process can elect to receive a reply to an Apple event. This can contain various bits of information returned from the target about
406-410: A process on the local or a remote machine), and various other options for handling it. Remote machines initially had to be connected via AppleTalk , but Mac OS 9 added the option for connections via TCP/IP . After sending an Apple event to its target process, the sending process can elect to receive a reply to an Apple event. This can contain various bits of information returned from the target about
464-465: A string. Many C compilers, including GCC, define a multi-character literal behavior of right-aligning to the least significant byte, so that '1234' becomes 0x3 1 3 2 3 3 3 4 in ASCII. This is the conventional way of writing FourCC codes used by Mac OS programmers for OSType. ( Classic Mac OS was exclusively big-endian.) On little-endian machines, a byte-swap on the value is required to make
522-450: A two-byte identifier, usually written in hexadecimal (such as 0055 for MP3 ). In QuickTime files, these two-byte identifiers are prefixed with the letters "ms" to form a four-character code. RealMedia files also use four-character codes, however, the actual codes used differ from those found in AVI or QuickTime files. Other file formats that make important use of the four-byte ID concept are
580-572: Is a sequence of four bytes (typically ASCII ) used to uniquely identify data formats . It originated from the OSType or ResType metadata system used in classic Mac OS and was adopted for the Amiga / Electronic Arts Interchange File Format and derivatives. The idea was later reused to identify compressed data types in QuickTime and DirectShow . In 1984, the earliest version of a Macintosh OS, System 1 ,
638-461: Is an AERecord with fields that depended on the purpose of the event. In addition, it has attributes (which are distinct from record fields, which are now called the parameters of the event) from a set predefined by the Apple Event Manager. These specify what the event is supposed to do (through event class and event ID ), the target address to which the event is to be sent (which could be
SECTION 10
#1733114222546696-399: Is an AERecord with fields that depended on the purpose of the event. In addition, it has attributes (which are distinct from record fields, which are now called the parameters of the event) from a set predefined by the Apple Event Manager. These specify what the event is supposed to do (through event class and event ID ), the target address to which the event is to be sent (which could be
754-510: Is just an OSType code specifying the data type, together with a block of type-dependent data. For instance, the OSType code inte indicates that the data was a four-byte signed integer in big-endian format. Besides predefined type codes for various common simple types, there are two predefined structured descriptor types: an AERecord , which has data type reco (record), and AEList with type list (list or array). The internal structure of these contain recursively-nested AEDescs, while
812-465: Is rare to find this kind of power in general-purpose scripting languages outside of SQL . Adding support for the AEOM in the classic Mac OS was a difficult process. Application developers had to identify their objects and hand-write code to allow them to be addressed. This typically took the form of code for returning the "next" object of a particular type, allowing AppleScript to iterate over them. But since
870-418: Is rare to find this kind of power in general-purpose scripting languages outside of SQL . Adding support for the AEOM in the classic Mac OS was a difficult process. Application developers had to identify their objects and hand-write code to allow them to be addressed. This typically took the form of code for returning the "next" object of a particular type, allowing AppleScript to iterate over them. But since
928-638: Is uncommon to find a Cocoa application that is not scriptable to some degree. The Scripting Bridge is a macOS framework which allows applications to communicate with each other without the use of an intermediary scripting language such as AppleScript . Like AppleScript, the Scripting Bridge uses Apple events for inter-application communication . The Scripting Bridge is typically used from Objective-C , but can be used in other programming languages through an Objective-C bridge such as MacRuby and PyObjC . OSType A FourCC ("four-character code")
986-419: Is used to map the internal "object-like" names onto human-readable versions, and in most cases creating this is all that is needed to add fairly substantial scriptability to most programs. While Cocoa applications are not AEOM based, and often use subtly different objects than Apple's originally defined standard objects, Cocoa apps are generally much more scriptable than their "classic" counterparts—in fact, it
1044-419: Is used to map the internal "object-like" names onto human-readable versions, and in most cases creating this is all that is needed to add fairly substantial scriptability to most programs. While Cocoa applications are not AEOM based, and often use subtly different objects than Apple's originally defined standard objects, Cocoa apps are generally much more scriptable than their "classic" counterparts—in fact, it
1102-614: The Cocoa API . Unofficial bindings also exist for other languages (with varying degrees of limitation), including Perl , UserTalk , Ruby and Python . The AppleEvent Object Model ( AEOM ) was a set of protocols built on top of AppleEvents by which applications running under classic Mac OS and macOS could control each other's functions. Applications that implemented some part of the AEOM were called scriptable because they could be controlled via AppleScript . Unfortunately, scriptability support remained patchy and inconsistent throughout
1160-563: The Cocoa API . Unofficial bindings also exist for other languages (with varying degrees of limitation), including Perl , UserTalk , Ruby and Python . The AppleEvent Object Model ( AEOM ) was a set of protocols built on top of AppleEvents by which applications running under classic Mac OS and macOS could control each other's functions. Applications that implemented some part of the AEOM were called scriptable because they could be controlled via AppleScript . Unfortunately, scriptability support remained patchy and inconsistent throughout
1218-586: The Interchange File Format (IFF) meta-format (family of file formats), originally devised for use on the Amiga . These files consisted of a sequence of "chunks", which could contain arbitrary data, each chunk prefixed by a four-byte ID. The IFF specification explicitly mentions that the origins of the FourCC idea lie with Apple. This IFF was adopted by a number of developers including Apple for AIFF files and Microsoft for RIFF files (which were used as
SECTION 20
#17331142225461276-699: The Standard MIDI File (SMF) format, the PNG image file format, the 3DS (3D Studio Max) mesh file format and the ICC profile format. Four-character codes are also used in applications other than file formats, for example: Other uses for OSTypes include: AppleEvents Apple events are the message-based interprocess communication mechanism in Mac OS , first making an appearance in System 7 and supported by every version of
1334-583: The classic Mac OS since then and by macOS . Apple events describe "high-level" events such as "open document" or "print file", whereas earlier OSs had supported much more basic events, namely "click" and "keypress". Apple events form the basis of the Mac OS scripting system, the Open Scripting Architecture (the primary language of such being AppleScript ). The starting point is a dynamically-typed, extensible descriptor format called an AEDesc , which
1392-429: The AEOM considerably easier, dramatically reducing the amount of code needed in the average application. Additionally the majority of Cocoa applications are constructed primarily from Cocoa-standard objects, all of which were upgraded to offer fairly extensive scriptability. This extends not only to GUI objects as under MacApp, but also to data objects inside them, including text, tables and various list objects. A text file
1450-429: The AEOM considerably easier, dramatically reducing the amount of code needed in the average application. Additionally the majority of Cocoa applications are constructed primarily from Cocoa-standard objects, all of which were upgraded to offer fairly extensive scriptability. This extends not only to GUI objects as under MacApp, but also to data objects inside them, including text, tables and various list objects. A text file
1508-629: The AERecord also associates each element with a unique record field ID, which is an OSType. The Apple Event Manager provides API calls to construct these structures, as well as extract their contents and query the type of contents they hold. The Apple Event Manager also supports coercions , which converts AEDescs from one data type to another. In addition to standard coercions, for instance between integer and real types, applications can install their own coercion handler callbacks , which handle conversions to and from custom data types. An Apple event proper
1566-578: The AERecord also associates each element with a unique record field ID, which is an OSType. The Apple Event Manager provides API calls to construct these structures, as well as extract their contents and query the type of contents they hold. The Apple Event Manager also supports coercions , which converts AEDescs from one data type to another. In addition to standard coercions, for instance between integer and real types, applications can install their own coercion handler callbacks , which handle conversions to and from custom data types. An Apple event proper
1624-495: The OS did not contain an object model, this work was left entirely to the developers, many of whom did not implement it. Oddly, even Apple's own application framework , MacApp , did not offer such a model except for the GUI objects it knew about, once again making the developer do most of the work of scripting the objects representing the data itself. Largely for these reasons, AppleScript support
1682-405: The OS did not contain an object model, this work was left entirely to the developers, many of whom did not implement it. Oddly, even Apple's own application framework , MacApp , did not offer such a model except for the GUI objects it knew about, once again making the developer do most of the work of scripting the objects representing the data itself. Largely for these reasons, AppleScript support
1740-479: The application might have one or more window elements representing windows showing the contents of currently-open documents. These windows might have properties such as their title, position and size. An application could define custom verbs for operating on its objects. The AEOM also specified various standard verbs which (it was hoped) applications would implement in a consistent fashion, such as open, close, create element, delete, set data, and get data. Each verb
1798-479: The application might have one or more window elements representing windows showing the contents of currently-open documents. These windows might have properties such as their title, position and size. An application could define custom verbs for operating on its objects. The AEOM also specified various standard verbs which (it was hoped) applications would implement in a consistent fashion, such as open, close, create element, delete, set data, and get data. Each verb
Apple event - Misplaced Pages Continue
1856-607: The basis for the AVI and WAV file formats). Apple referred to many of these codes as OSTypes . Microsoft and Windows developers refer to their four-byte identifiers as FourCCs or Four-Character Codes . FourCC codes were also adopted by Microsoft to identify data formats used in DirectX , specifically within DirectShow and DirectX Graphics. Since Mac OS X Panther , OSType signatures are one of several sources that may be examined to determine
1914-437: The correspondence between internal AppleEvent codes and external natural-language descriptions is specified through the aete ( AppleEvent Terminology Extension ) resource — the "extension" being to the standard terminology built into AppleScript itself. An application may provide multiple 'aete' resources for multiple languages, in keeping with the original multilingual design of AppleScript itself For instance, consider
1972-437: The correspondence between internal AppleEvent codes and external natural-language descriptions is specified through the aete ( AppleEvent Terminology Extension ) resource — the "extension" being to the standard terminology built into AppleScript itself. An application may provide multiple 'aete' resources for multiple languages, in keeping with the original multilingual design of AppleScript itself For instance, consider
2030-505: The developer could at least reduce the workload of planning how to expose their objects. Yet because these objects were generally not part of the system itself (with the exception of the severely limited TextEdit editor), the actual implementation was left to the developer. Applications developed in Cocoa , the system formerly known as OpenStep , offer a rich object runtime that can be queried from any other application. This makes implementation of
2088-458: The developer could at least reduce the workload of planning how to expose their objects. Yet because these objects were generally not part of the system itself (with the exception of the severely limited TextEdit editor), the actual implementation was left to the developer. Applications developed in Cocoa , the system formerly known as OpenStep , offer a rich object runtime that can be queried from any other application. This makes implementation of
2146-431: The following AppleScript sequence controlling a fictional drawing application: This actually involves the sending of two AppleEvents to the target application (and the receipt of their corresponding replies): first, a get-data event is sent to retrieve the background color property of the window identified by the name "Old Drawing"; then a set-data event is sent to apply the value returned as the background color property of
2204-431: The following AppleScript sequence controlling a fictional drawing application: This actually involves the sending of two AppleEvents to the target application (and the receipt of their corresponding replies): first, a get-data event is sent to retrieve the background color property of the window identified by the name "Old Drawing"; then a set-data event is sent to apply the value returned as the background color property of
2262-411: The four-byte memory space typically allocated for integers in 32-bit systems (although endian issues may make them less readable). Thus, the codes can be used efficiently in program code as integers, as well as giving cues in binary data streams when inspected. FourCC is written in big endian relative to the underlying ASCII character sequence, so that it appears in the correct byte order when read as
2320-418: The history of classic Mac OS. The AEOM provided a syntactic layer under which any application could publish its internal objects, allowing those objects to be manipulated in a standardized way. Unlike other similar-sounding concepts such as ToolTalk , there was a clear, orthogonal distinction between nouns and verbs ; thus, instead of providing separate commands for "close document" and "close window", there
2378-418: The history of classic Mac OS. The AEOM provided a syntactic layer under which any application could publish its internal objects, allowing those objects to be manipulated in a standardized way. Unlike other similar-sounding concepts such as ToolTalk , there was a clear, orthogonal distinction between nouns and verbs ; thus, instead of providing separate commands for "close document" and "close window", there
Apple event - Misplaced Pages Continue
2436-539: The macOS command line tools GetFileInfo and SetFile which are installed as part of the developer tools into /Developer/Tools , or the ResEdit utility available for older Macs. The byte sequence is usually restricted to ASCII printable characters , with space characters reserved for padding shorter sequences. Case sensitivity is preserved, unlike in file extensions . FourCCs are sometimes encoded in hexadecimal (e.g., "0x31637661" for ' avc1 ') and sometimes encoded in
2494-688: The processing of the original event, including an error code indicating success/failure, any information requested by the original event, and/or other appropriate information. Apple events are the foundation of the AppleEvent Object Model , which in turn is the foundation of the OSA and AppleScript . As of 2016 , the official implementation of the Apple Event Manager API is available in C and its descendants, including C++ . Official bindings are also provided for Objective-C and Swift through
2552-511: The processing of the original event, including an error code indicating success/failure, any information requested by the original event, and/or other appropriate information. Apple events are the foundation of the AppleEvent Object Model , which in turn is the foundation of the OSA and AppleScript . As of 2016, the official implementation of the Apple Event Manager API is available in C and its descendants, including C++ . Official bindings are also provided for Objective-C and Swift through
2610-450: The reply event. The "set data" event took two parameters, the object descriptor for the property to set and the new value for the property; the reply event was only expected to return a success status or failure error code. The entire AppleEvent architecture identifies things using four-byte OSType codes, studiously avoiding actual words or phrases in English (or any other language). Instead,
2668-400: The reply event. The "set data" event took two parameters, the object descriptor for the property to set and the new value for the property; the reply event was only expected to return a success status or failure error code. The entire AppleEvent architecture identifies things using four-byte OSType codes, studiously avoiding actual words or phrases in English (or any other language). Instead,
2726-566: The result correct. Taking the avc1 example from above: although the literal 'avc1' already converts to the integer value 0x61766331 , a little-endian machine would have reversed the byte order and stored the value as 31 63 76 61 . To yield the correct byte sequence 61 76 63 31 , the pre-swapped value 0x31637661 is used. One of the most well-known uses of FourCCs is to identify the video codec or video coding format in AVI files. Common identifiers include DIVX , XVID , and H264 . For audio coding formats , AVI and WAV files use
2784-478: The window named "New Drawing". Since this sort of access pattern was typical, AppleScript made widespread use of the tell statement, which switched the context to the named object in a fashion similar to the with statement found in Visual Basic or Pascal . All commands after the tell to the corresponding end tell would be sent to the object named in the tell , instead of the default object, which
2842-424: The window named "New Drawing". Since this sort of access pattern was typical, AppleScript made widespread use of the tell statement, which switched the context to the named object in a fashion similar to the with statement found in Visual Basic or Pascal . All commands after the tell to the corresponding end tell would be sent to the object named in the tell , instead of the default object, which
2900-453: Was a single "close" verb which could take references to "document" or "window" objects, or any other object that the application published. The objects that an application made available through its AEOM support were arranged in a hierarchy. At the top was the application itself, referenced via a null object descriptor. Other objects were referenced by (recursively) specifying their parent object, together with other information identifying it as
2958-453: Was a single "close" verb which could take references to "document" or "window" objects, or any other object that the application published. The objects that an application made available through its AEOM support were arranged in a hierarchy. At the top was the application itself, referenced via a null object descriptor. Other objects were referenced by (recursively) specifying their parent object, together with other information identifying it as
SECTION 50
#17331142225463016-399: Was defined as an AppleEvent of a specific type and class, together with particular parameters of particular types that were expected to be present. For instance, the "get data" event was the standard means for obtaining the value of a property: it took essentially one parameter, which was an object descriptor identifying the property to be queried. The value of that property would be returned in
3074-399: Was defined as an AppleEvent of a specific type and class, together with particular parameters of particular types that were expected to be present. For instance, the "get data" event was the standard means for obtaining the value of a property: it took essentially one parameter, which was an object descriptor identifying the property to be queried. The value of that property would be returned in
3132-422: Was not very widespread. Apple did attempt to address this problem with the introduction of various object "suites", which represented standard objects and verbs that were expected to be supported by different types of applications. For instance, all applications were expected to support the "core suite", and any application editing text was expected to support the "text suite". By selecting a suitable set of suites,
3190-422: Was not very widespread. Apple did attempt to address this problem with the introduction of various object "suites", which represented standard objects and verbs that were expected to be supported by different types of applications. For instance, all applications were expected to support the "core suite", and any application editing text was expected to support the "text suite". By selecting a suitable set of suites,
3248-438: Was released. It used the single-level Macintosh File System with metadata fields including file types , creator (application) information , and forks to store additional resources . It was possible to change this information without changing the data itself, so that they could be interpreted differently. Identical codes were used throughout the system, as type tags for all kinds of data. In 1985, Electronic Arts introduced
3306-535: Was the current application. Object descriptors allowed the identification of objects in various ways. The most interesting one was using a where-clause (which translated into AppleScript terminology as a filter expression ). For instance, the AppleScript 1.0 SDK shipped with the source code for an example application called the Scriptable Text Editor, which would respond to scripts such as: Even today, it
3364-416: Was the current application. Object descriptors allowed the identification of objects in various ways. The most interesting one was using a where-clause (which translated into AppleScript terminology as a filter expression ). For instance, the AppleScript 1.0 SDK shipped with the source code for an example application called the Scriptable Text Editor, which would respond to scripts such as: Even today, it
#545454