LNS Home
JavaScript OSA
JavaScript OSA Home
Download & Installation
QuickStart
Project Status
Documentation
 
Object Reference
 
Core
MacOS
MacOS.AEDesc
MacOS.AEApp
MacOS.AEClass
MacOS.AEColl
MacOS.FileSpec
MacOS.OSA
MacOS.MacOSError
Sending Raw AppleEvents
Responding to AppleEvents
AppleEvent to JavaScript Value Conversion
How-Tos
 
Open Handler
Folder Actions Handlers
Write Some Text
Calling JavaScript from REALbasic
Using JavaScript Libraries
FAQ
Mailing List
JavaScript Language Documentation & Links
Products
Affrus 1.0
x FaceSpan 4.3
Script Debugger 4.0
Site Contents
Home Page
bullet Mark’s Blog
Product Registration
Bug Reporting
x Freeware
Contacting Us

MacOS.AEApp object

The MacOS.AEApp object represents a running MacOS application. You can use the MacOS.AEApp object to send AppleEvents to any AppleEvent aware application.

Instances of the MacOS.AEApp are created by the MacOS.appSelf() and MacOS.appBySignature() methods. For example, the following statement creates an instance of MacOS.AEApp targeting the MacOS Finder:

Sample
var finder = MacOS.appBySignature("MACS");

NOTE: Instances of this class cannot be created using the JavaScript new operator.

In addition to the methods described below, the MacOS.AEApp object supports all of the functionality of the MacOS.AEClass object. The MacOS.AEApp refers to the target application's "Application" object, and thus provides access to all the properties, collections and events of that object in addition to the properties and methods described below.

Method/Property Description
MacOS.AEApp.sendAE (suiteID, eventID, params, ...)

send an Raw AppleEvent to the target application, waiting for and returning a result.

SuiteID and EventID are the 4-character AppleEvent suite and event IDs respectively. All remaining parameters are added as parameters of the AppleEvent.

If the params argument is a JavaScript object, its properties are added as parameters of the event. Properties must be named "ae_XXXX" where XXXX is the parameter's 4-character ID.

If the params argument is a MacOS.AEDesc object and that object contains an AppleEvent Record (typeAERecord), each property of that record are added to the AppleEvent as a parameter.

In all other cases, the params value is added to the AppleEvent as the direct object (keyDirectObject/'----').

MacOS.AEApp.sendAENoReply (suiteID, eventID, params, ...)

send an Raw AppleEvent to the target application, without waiting for a reply

MacOS.AEApp._strict

(default = true)
When true, JavaScript OSA strictly enforces class/property and class/containment relationships as defined in the applications dictionary ('aete').

When false, JavaScript OSA operates in a manner similar to AppleScript where you can use any property with any class and you can access any collection from any class.

MacOS.AEApp._path

read-only
returns a MacOS.FileSpec object referring to the target application

MacOS.AEApp._timeout

the length of time, expressed in MacOS Ticks, that JavaScript OSA will wait for AppleEvents to complete.

NOTE: this timeout value is shared by all instances of MacOS.AEClass and MacOS.AEColl that derive from this instance of MacOS.AEApp.

MacOS.AEApp.beginning

returns a MacOS.AEClass object representing an insertion location before all objects in this container

MacOS.AEApp.atBeginning
MacOS.AEApp.toBeginning

returns an instance of MacOS.AEDesc containing an insertion location suitable for use with the at parameter of make, copy, duplicate and move events

MacOS.AEApp.end

returns a MacOS.AEClass object representing an insertion location after all objects in this container

MacOS.AEApp.atEnd
MacOS.AEApp.toEnd

returns an instance of MacOS.AEDesc containing an insertion location suitable for use with the at parameter of make, copy, duplicate and move events

Invoking Scripting Additions

The MacOS.AEApp class also provides access to all AppleScript Scripting Additions. As it does for AppleEvents defined by the application;s dictionary, the MacOS.AEApp class provides JavaScript functions for each Scripting Addition command.

When invoking a scripting addition, you can use positional or named syntax as described in the documentation for MacOS.AEClass. The difference is that the direct object parameter must always be specified as the first parameter of the function. If you don't want to specify a direct object parameter then specify Null as the first parameter of the function.

Sample
// display a dialog box in the Finder
with (MacOS.finder())
    display_dialog("Hello World", null, ["Button 1", "Button2"]).button_returned;

// in AppleScript, this would be expressed as
//
// tell application "Finder"
//     button returned of (display dialog "Hello World" buttons {"Button 1", "Button 2"}
// end tell

 


Copyright © 1998-2007 Late Night Software Ltd. - All Rights Reserved.