Re: Apple Events in Cocoa
Re: Apple Events in Cocoa
- Subject: Re: Apple Events in Cocoa
- From: Mark Hatton <email@hidden>
- Date: Mon, 27 May 2002 01:31:17 -0500
On Thu, 23 May 2002 09:19:32 -0700, Matt Neuburg wrote:
We can now write a routine for making the Finder reveal any file:
- (void) revealFile: (NSString*) filepath {
AppleEvent event, reply;
OSErr err;
OSType adrFinder = 'MACS';
FSRef fileRef;
AliasHandle fileAlias;
err = FSPathMakeRef([filepath fileSystemRepresentation], &fileRef,
NULL);
if (err != noErr) return;
err = FSNewAliasMinimal(&fileRef, &fileAlias);
if (err != noErr) return;
err = AEBuildAppleEvent
('misc', 'mvis', typeApplSignature, &adrFinder,
sizeof(adrFinder),
kAutoGenerateReturnID, kAnyTransactionID, &event, NULL,
"'----':alis(@@)", fileAlias);
if (err != noErr) return;
err = AESend(&event, &reply, kAEWaitReply, kAENormalPriority,
kAEDefaultTimeout, NULL, NULL);
AEDisposeDesc(&event);
AEDisposeDesc(&reply);
return;
}
I tried to adapt that to this:
- (void)activateFinder{
AppleEvent event, reply;
OSErr err;
OSType adrFinder = 'MACS';
err = AEBuildAppleEvent
('aevt', 'oapp', typeApplSignature, &adrFinder,
sizeof(adrFinder),
kAutoGenerateReturnID, kAnyTransactionID, &event, NULL,
"");
if (err != noErr) return;
err = AESend(&event, &reply, kAEWaitReply, kAENormalPriority,
kAEDefaultTimeout, NULL, NULL);
AEDisposeDesc(&event);
AEDisposeDesc(&reply);
[NSTimer scheduledTimerWithTimeInterval:0.5 target:NSApp
selector:@selector(terminate:) userInfo:nil repeats:NO];
return;
}
to restart the Finder after I kill it with a similar method. No matter
what event code I try, I can not wake the Finder. I have also tried the
codes for launch and activate that I gleaned from Script Debugger.
(Thanks for that tip!) I'm guessing that my error is coming from
something else. I did notice in SD that whatever "Start" command I send
to the Finder via SD, it is sent a few times, not just once. Is this the
source of my problem? If I send the 'activate' code to the Finder
without killing it first, it does activate. So how do I revive a dead
Finder?
I think my problem is with the AESend(), but i can't find the docs.
Love,
The Server Surfer
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.