At 2:23 pm +0100 02/06/02, I wrote:
>At 2:44 pm -0400 01/06/02, Chris Nandor wrote:
>>No, I mean *hidden*. Try:
>>
>> use Mac::Apps::Launch;
>> Hide('GKON');
>>
>>Then send events to it, and you won't see the window, because
>>GraphicConverter will be hidden (assuming it is already running).
>
>Brilliant. That does the trick nicely.
>
>However there is a glitch. Running this script:
>
> if (!IsRunning('GKON')) { LaunchApps('GKON')}
> Hide('GKON');
>
>If 'GraphicConverter' is not running, then it is launched but the
>'Hide' event fails:
This seems to be a system timing problem (?). Repeated 'hide' calls
eventually succeed. It can take five or six seconds however.
If anyone wants to play the script below demonstrates the phenomenon.
Alan Fry
------
#!perl -w
use Mac::Processes;
use Mac::Apps::Launch;
use Mac::AppleEvents;
use strict;
if (!IsRunning('GKON')) { LaunchApps('GKON')}
hide('GKON');
sub hide {
my($app) = @_;
my $q = 1;
my $m;
my $n = 0;
foreach my $psn (keys %Process) {
if ($Process{$psn}->processSignature eq $app) {
$app = $Process{$psn}->processName;
$m = $n;
last;
}
$n++;
}
while ($q) {
my $evt = AEBuildAppleEvent('core', 'setd', 'sign', 'MACS', 0, 0,
qq('----': obj {form:prop,
want:type(prop),
seld:type(pvis),
from:obj {form:indx,
want:type(pcap),
seld:TEXT(@),
from:'null'()
}
}, data:fals), $m);
my $rep = AESend($evt, kAEWaitReply);
#print AEPrint($evt), "\n";
print AEPrint($rep), "\n";
my $error = AEGetParamDesc($rep, 'errn');
AEDisposeDesc $evt if $evt;
AEDisposeDesc $rep if $rep;
AEDisposeDesc $error if $error;
$q = $error ? 1 : 0;
}
}
---------