Re: Can a script receive AppleEvents?
Re: Can a script receive AppleEvents?
- Subject: Re: Can a script receive AppleEvents?
- From: Bill Peters <email@hidden>
- Date: Tue, 14 Nov 2000 09:36:21 -0700
At 12:46 PM -0800 11/13/00, Rick Mann wrote:
>
I'd like to write a script designed to respond to specific AppleEvents. I
>
would then like to have that script redirect the event to an app on a
>
different machine.
>
I can't say for certain that you can make a script respond to any given
apple event, but I suspect that this is so. I have a program which launches
a saved-as-application script using the LaunchApplication API and packages
the initial appleevent in the launchAppParameters parameters of the
LaunchParamBlockRec. In my script, my handler looks like this:
on +event ADExRunS; given +class ssid;:keyID
-- handle the event. note that ADEx and RunS are the event class and ID
-- of the apple event I am sending to the script. the ssid value was added
-- to the apple event by AEPutParamDesc(&theEvent, typeSessionID, &theDesc);
end +event ADExRunS;
Doing this allows me to bypass the run handler in the scrip. I then put a
display dialog in my run handler to tell the user that the script is part
of an application package and is not designed to be run independantly.
For your purposes, you would have to define a handler for every event you
want to redirect and supply the required parameters in the _given_ portion
of the handler. It would probably take a lot of work to get everything just
right, and there may be issues with timeouts or packaging the reply
correctly.
On the other hand, it may be easier to write a small program to respond to
every event (using the wildcard values in AEInstallEventHandler), replace
what you must in order to redirect the event to your remote program, and
then send it on its way. Then you wouldn't have to worry about extracting
the data from the event and repackaging it. In the Folder Actions sample
code package in the AppleScript SDK there is an example of redirecting an
event from an FBA to the Finder which may help you do that.
Good Luck,
Bill Peters
Red Rock Software