I\'m observing NSWorkspaceDidDeactivateApplicationNotification notification to get the application that has just lost focus. I\'m ending up with an instance of NSRunningAppl
It's very difficult to get the main window of other apps; they're not even guaranteed to be Cocoa! They can be either Carbon or Java, or Qt, or Mono... So there's no way you can get NSWindow of another app, unless you do a hack. You can try Accessibility API to get the window info etc. of other apps independently of the framework used, but it's not so easy to use.