I'm looking for a way to determine the second frontmost app. Here's what I mean by that.
Let's say I launch three apps in this order: Xcode, Interface Builder, and my application. If I press Command-tab, I should see four applications in the switcher: (from left to right) my application, Interface Builder, Xcode, and Finder.
Let's then say that I switch to Finder. The new order in the app switcher is: Finder, my application, Interface Builder, and Xcode.
If I then switch back to my application, the order is now my application, Finder, Interface Builder, and Xcode.
I'm looking for an API whereby I can call it and get back that at launch time Interface Builder is the second frontmost app, but that when I switch back to it, it is now Finder.
If it makes any different, my app won't actually appear in the app switcher, since it will be an agent application (LSUIElement = YES).
Is there an API that can do this? The only alternative I've found is to have a timer running that continuously monitors what the activeApplication is, according to NSWorkspace. This works well, except during launch. I'd like to know the second frontmost application at launch, if possible.
Any ideas?