Re: how to hide/show/bring to front apps with Cocoa?
Re: how to hide/show/bring to front apps with Cocoa?
- Subject: Re: how to hide/show/bring to front apps with Cocoa?
- From: petite_abeille <email@hidden>
- Date: Sat, 13 Jul 2002 20:13:33 +0200
On Saturday, July 13, 2002, at 03:35 , Finlay Dobbie subtly proclaimed:
This is completely evil and disgusting and vomit-inducing. Don't do it.
(Not to mention not all apps have an NSApplication).
Thanks for your acute input :-) Always a pleasure to hear the voice of
reason incarnated.
You can send AppleScripts/AppleEvents to the
/System/Library/CoreServices/System Events.app to do what you want.
Otherwise, just use Carbon. There's no good reason not to. Carbon
Process Manager is just a thin wrapper around Core Process Services,
which is how this sort of thing is dealt with internally by the
windowserver et al.
Talking of which, where is this fabled "Core Process Services"? I
venture that's what I'm after.
petite_abeille, Nathan Day provided a link to a Cocoa WRAPPER for the
Carbon functionality, so you don't even have to call the Carbon
functions yourself.
Yep. In any case, the Carbon calls don't amount to much:
@implementation PSProcess (CarbonAdditions)
- (ProcessSerialNumber) processSerialNumber
{
int aProcessIdentifier = [self processIdentifier];
ProcessSerialNumber aProcessSerialNumber;
OSStatus aStatus = GetProcessForPID( aProcessIdentifier, &
aProcessSerialNumber );
if ( aStatus == noErr )
{
return aProcessSerialNumber;
}
return aProcessSerialNumber;
}
- (void) hide
{
ProcessSerialNumber aProcessSerialNumber = [self processSerialNumber];
ShowHideProcess( &aProcessSerialNumber, false );
}
- (void) show
{
ProcessSerialNumber aProcessSerialNumber = [self processSerialNumber];
ShowHideProcess( &aProcessSerialNumber, true );
}
- (void) makeFront
{
ProcessSerialNumber aProcessSerialNumber = [self processSerialNumber];
SetFrontProcess( &aProcessSerialNumber );
}
@end
What more could you ask for?
Where is this legendary "Core Process Services" your are babbling about?
This is what would happen if Apple wrote support for it and added it to
NSWorkspace.
Ummm... Whatever.
Please guys, stop being so anti-Carbon. If it's there and it works, use
it.
Wise words.
Thanks Finlay.
PA.
_______________________________________________
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.