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

Re: [MacPerl] Apple Events without parameters



At 17:47 -0500 1999.10.21, gibson wrote:
>I'm trying to get into AppleEvents using MacPerl, and I want to start with
>something simple.  However, I'm still getting stuck :-(
>
>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).


>So, I shouldn't need any parameters, my event class is aevt, my event
>id=oapp etc.  I keep getting an error from my AEBuildAppleEvent command, so
>I'm pretty sure I've got that wrong (I've tried a number of variations,
>below I'm just including one ;-).
>
>If anybody has any pointers on creating AppleEvents without parameters, I'd
>be very grateful!
>
>Thanks,
>Rick
>
>#!perl -w
>
>use Mac::AppleEvents;
>
>my $ae;
>
>%ae = (
>target => 'MSIE',      # creator ID
>class => 'aevt',       # event class
>id => 'oapp',
>params => ("'----':obj{want:null(),from:null(), form:null(), seld:null()}")
>);

A few problems.

1.  params here should be an anonymous array, not a list.  So it would be:

  params => ["'----':...."]

However, in this case it would not matter so much, because your "list" is
only one element, that string.  How do you create an Apple event without
parameters?  You just ... don't make parameters.  You can do:

  params => []

Or you can remove the "@{$ae{'params'}" from the AEBuildAppleEvent call.


># now build apple event
>$event = AEBuildAppleEvent(
>    $ae{'class'},
>    $ae{'id'},
>    'sign',
>    $ae{'target'},
>    0,
>    0,
> @{$ae{'params'}}
>) or die($^E);

This could just be:

  $event = AEBuildAppleEvents($ae{'class'}, $ae{'id'},
    'sign', $ae{'target'}, 0, 0) or die $^E;

You'd be better off, though, with Mac::AppleEvents::Simple.

  use Mac::AppleEvents;
  do_event($ae{'class'}, $ae{'id'}, $ae{'target'});
  die $^E if $^E;

-- 
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