[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Apple Events without parameters



At 9:52 -0500 1999.10.22, gibson wrote:
>on 10/21/99 18:04, Chris Nandor at pudge@pobox.com wrote:
>
>>> My script is supposed to be a simple modification of the example in the
>>> macperlcat.pod (posted below).  All I want to do, for now, is just to
>>>launch
>>> Internet Explorer.  The relevant event description from aete.converter is:
>>
>> You can't do that.  After an app is launched, it is sent the oapp event.
>> To merely launch an app, you can tell the Finder to open it, or use
>> Mac::Processes (or Mac::Apps::Launch for a simpler interface).
>
>Thanks for your rapid and helpful answers.  The key for me was
>Mac::AppleEvents::Simple (I like simple!).
>
>However, I still am curious about your statement above.  Although you say I
>can't directly launch my app, the script below does just that.  Why is this?

Because Mac::AppleEvents::Simple uses Mac::Apps::Launch.  :)  It first
looks to see if the app is running, and if not, it launches it.  Any event
sent would launch the app if it wasn't already running.  What oapp does is
send the app a signal like "hey, you were just opened, so now do whatever
it is that you do when you are just opened."  So if an app opens a new
window when launched, then sending the oapp event repeatedly will open new
windows.

>#!perl -w
>
>use Mac::AppleEvents;
>use Mac::AppleEvents::Simple;
>
> %ae = (
> target => 'MSIE',# creator ID
> class=> 'aevt',# event class
> id=> 'oapp'# event ID
>);
>
>do_event($ae{'class'}, $ae{'id'}, $ae{'target'});
>die $^E if $^E;

(Note: you don't need to "use Mac::AppleEvents" if you "use
Mac::AppleEvents::Simple".)

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org