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

[MacPerl-Toolbox] Apple events and PSN ... bug?



This seems to me it should work.  I confirm that the PSN I get from
Mac::Processes (in this case, 8208) is indeed the decimal number
corresponding to the hex PSN that an app called Process Watcher tells me is
assigned to BBEdit (2010).  So I seem to have the right number.  But the
script produces:

PSN: 8208
# No eligible process with specified process serial number  (OS error -600).
File 'Bourque:Desktop Folder:Untitled #3'; Line 17
# theAEDesc is not of type AEDesc.
File 'Bourque:Desktop Folder:Untitled #3'; Line 20

So I dunno what's wrong.  Just wondering if anyone else has had a problem
with this, or if anyone has gotten it to work.

#!perl -wl
use Mac::AppleEvents;
use Mac::Processes;
use strict;

my($psn, $evt, $rep);

foreach (keys %Process) {
  $psn = $_ if $Process{$_}->processName =~ /BBEdit/;
}
die "App not found" unless $psn;
print "PSN: $psn";

$evt = AEBuildAppleEvent(qw(aevt quit), typeProcessSerialNumber, $psn,
    kAutoGenerateReturnID, kAnyTransactionID, '') or warn $^E;

$rep = AESend($evt, kAEWaitReply) or warn $^E;

AEDisposeDesc($evt);
AEDisposeDesc($rep);

--
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-toolbox-request@macperl.org