Re: [MacPerl-Toolbox] AppleEvents and GraphicConverter

[email protected] (Alan Fry) Sun, 2 Jun 2002 14:23:16 +0100
Newsgroups perl.macperl.toolbox
Message-ID <p05100300b91fc6246f71@[158.152.146.73]>
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:

fals, GKON,
$app = GraphicConverter

core\setd{'----':obj {form:prop, want:type(prop), seld:type(pvis),
  from:obj {form:name, want:type(pcap), seld:"GraphicConverter", 
from:'null'()}},
  data:fals, &inte:cans, &timo:3600}

aevt\ansr{errn:-1728,
  erob:obj {want:type(pcap), from:'null'(), form:name, seld:"GraphicConverter"}}

If the script is re-run (i.e. GraphicConverter still running) the 
'Hide' event works fine. The event seems identical in both cases.

fals, GKON,
$app = GraphicConverter

core\setd{'----':obj {form:prop, want:type(prop), seld:type(pvis),
  from:obj {form:name, want:type(pcap), seld:"GraphicConverter", 
from:'null'()}},
  data:fals, &inte:cans, &timo:3600}

aevt\ansr{}

The odd thing is that in the first case (failure) the loop in "sub 
_showhide" (which gets the name from the process number) works 
properly returning the string "GraphicConverter". So GraphicConverter 
can be 'seen'. But the event nevertheless fails with error 1728 -- 
'AENoSuchObject'. Why should that be?

Any ideas?

Alan Fry