Getting the main window of an app via an NSRunningApplication instance

后端 未结 3 1510
醉梦人生
醉梦人生 2020-12-11 05:54

I\'m observing NSWorkspaceDidDeactivateApplicationNotification notification to get the application that has just lost focus. I\'m ending up with an instance of NSRunningAppl

3条回答
  •  失恋的感觉
    2020-12-11 05:59

    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.

提交回复
热议问题