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
x Script Debugger 4.5
Site Contents
bullet Mark’s Blog
Product Registration
Bug Reporting
x Freeware
Contacting Us

Sending Raw AppleEvents

Sending Raw AppleEvents is a two step process:

Step 1 - Identify the target application

This is done using the MacOS.appSelf() or MacOS.appBySignature() methods. MacOS.appSelf() targets the currently running application while MacOS.appBySignature() targets any other running application on your Macintosh.

For instance, to target the MacOS Finder:

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

Step 2 - Construct and send the AppleEvent

Once you have created a target for the AppleEvent, you can use the following syntax to send an AppleEvent:

Sample
var result = target.sendAE(suiteID, eventID, parameters);

Putting these two steps together, the following script tells the Finder to display a dialog box containing a message:

Sample

var target = MacOS.appBySignature("MACS");
var result = target.sendAE("syso", "dlog",
    {"ae_----":"Hello World", "AE_btns":["OK"], "AE_dflt":1, "AE_disp":1});



Result


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