API来获取其他应用程序的窗口/文档名称

编程入门 行业动态 更新时间:2024-10-26 20:23:50
本文介绍了API来获取其他应用程序的窗口/文档名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在可可中有一个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] 他们。具体来说,对于文档窗口,

For your own app, use [NSApp windows] to get an array of them. For document windows specifically, ask the document controller.

对于其他应用程式,请使用辅助功能或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来获取其他应用程序的窗口/文档名称

本文发布于:2023-10-23 22:28:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522183.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   窗口   名称   文档   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!