In 10.6 or later, if you do need to know when apps are being activated, you can also uses the NSWorkspace notificationCenter and observe NSWorkspaceDidActivateApplicationNotification with something like this:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(appWasActivated:) name:NSWorkspaceDidActivateApplicationNotification object:nil]; There are lots of other fun notifications in NSWorkspace to see what is going on outside of your app. Mark 2011/2/9 Mr. Gecko <grmrge...@gmail.com>: > I'm looking for the process that was front before my application became > front. I was thinking in getting the process as this is what I did in my > menubar applications and I just stole code from them. I can do as Dave DeLong > said and hide the application using [[NSApplication sharedApplication] > hide:self]; and it does infact brings the finder to the front. This is an > option with this application as I don't open any other window than the one > when you open the application from the finder. But with other applications, > it's not an option as there may be multiple windows for that one application > open and when you hide, it will also hide the other windows they had open. I > would be wondering how I can get the last front application (kinda how the > dock does) so if I need to write an application in the future that needs > multiple windows and also needs to be a UIAgent it would do the proper thing. > I don't need to know this now, if it's not possible than fine, but if anyone > out there knows how and wants to share, please do. > > On Feb 9, 2011, at 10:33 AM, Peter Lübke wrote: > >> GetNextProcess() doesn't reflect the order in which processes were made >> front, as the Process Manager doc says: >> "Note that the order of the list of processes is internal to the >> Process Manager" >> which *seems* to be the order in which processes register with Process >> Manager; if this is true (I don't know whether you can rely on it), you >> could at least use GetNextProcess() to track the (backwards) order in which >> processes registered with process manager. >> >> An easy way to look at this is an AppleScript: >> >> tell application "System Events" >> name of every process >> end tell >> >> I don't quite understand the scenario though: are you looking for the >> process that was front before the user launched your application? >> >> Cheers >> -Peter > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/unmarked%40gmail.com > > This email sent to unmar...@gmail.com > -- Mark Munz unmarked software http://www.unmarked.com/ _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com