如何遍历OS X中其他应用程序的窗口/视图层次结构? [英] how to traverse window/view hierarchy of other application in OS X?
问题描述
我试图弄清楚如何获取(只读)任何应用程序的整个窗口/视图层次结构.我使用"CGWindowListCopyWindowInfo"
获取所有打开的窗口的列表.它还返回窗口号("kCGWindowNumber"
).它还显示"kCGWindowSharingState = 1;"
的根窗口共享状态.现在,我要检查该应用程序的层次结构中是否存在特定的窗口/视图.我得到了kCGWindowNumber
,它是应用程序的根窗口.
I am trying to figure out how to get(read only) entire window/view hierarchy of any application. I get list of all open windows using "CGWindowListCopyWindowInfo"
. It also returns window number("kCGWindowNumber"
). It also shows sharing status of root window by "kCGWindowSharingState = 1;"
. Now, I want to check that a particular window/view present in hierarchy of that application. I got kCGWindowNumber
which is root window of application.
推荐答案
现在可以通过Xcode的View Debugging功能来实现.要使用此功能:
This is now possible via the View Debugging features of Xcode. To use this:
- 像往常一样启动目标应用程序
- 启动Xcode,然后打开一个项目窗口(任何项目,可能需要是OS X而不是iOS)
- 加载后,使用调试">附加到进程"菜单选择目标应用
- 现在单击查看调试小按钮或再次使用菜单:调试>查看调试>捕获视图层次结构
这应该向您显示该应用程序视图的一种分解"视图,以及它们在Xcode左窗格中的关系树.
This should show you a sort of "exploded" view of the app's views as well as a tree of their relationships in Xcode's left pane.
这篇关于如何遍历OS X中其他应用程序的窗口/视图层次结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!