Re: Detecting Frontmost Application
Re: Detecting Frontmost Application
- Subject: Re: Detecting Frontmost Application
- From: Matt Neuburg <email@hidden>
- Date: Fri, 03 Feb 2006 16:07:12 -0800
- Thread-topic: Detecting Frontmost Application
On Fri, 3 Feb 2006 15:39:02 -0500, William Henderson
<email@hidden> said:
>I know this topic has been covered before but also that things
>changed with Tiger. According to http://www.cocoadev.com/index.pl?
>DetectingAppChange there is a way to do it via carbon, but is this
>the best way? Do you have to use carbon do do this or can it be done
>without?
I think Carbon Events is the only way now. But it works great (in Tiger).
Here is code:
EventTypeSpec eventType;
eventType.eventClass = kEventClassApplication;
eventType.eventKind = kEventAppFrontSwitched;
EventHandlerUPP handlerUPP = NewEventHandlerUPP(appSwitched);
InstallApplicationEventHandler (handlerUPP, 1, &eventType, self, NULL);
DisposeEventHandlerUPP(appSwitched);
And so:
pascal OSStatus appSwitched (EventHandlerCallRef nextHandler, EventRef
theEvent, void* userData) {
ProcessSerialNumber newSerial;
GetFrontProcess(&newSerial);
// other stuff goes here
return(CallNextEventHandler(nextHandler, theEvent));
}
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden