问题描述
在可可中有一个API,您可以在其中获取应用程序的窗口/文档名称?我已经有 [[NSWorkspace sharedWorkspace] launchedApplication]
来获取所有可用的应用程序,所以我可以访问包名称或进程ID。
Is there an API in cocoa in which you can grab an application's window/document name? I've already got [[NSWorkspace sharedWorkspace] launchedApplication]
to fetch all available applications, so I've got access to the bundle name or process id. What should I look into so that I can get other application's window/document name.
推荐答案
你假设应用程序有一个只有一个窗口。这不是真的;一个应用程序可以有很多窗口。
You're assuming that the application has only one window. This is not true; an application can have many windows.
对于自己的应用程序,使用 [NSApp windows]
他们。具体来说,对于文档窗口,或CGWindowList查看其窗口。没有简单的方法只要求文档窗口,因为并不是所有的应用程序都是基于文档的,并且并非所有基于文档的应用程序都基于NSDocument。
For other apps, use Accessibility or CGWindowList to look at their windows. There's no simple way to only ask for document windows, since not all apps are document-based and not all document-based apps are based on NSDocument.
这篇关于API来获取其他应用程序的窗口/文档名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!