how to traverse window/view hierarchy of other application in OS X?

一个人想着一个人 提交于 2019-12-06 00:16:35

This is now possible via the View Debugging features of Xcode. To use this:

  1. Start the target app running as you normally would
  2. Launch Xcode, and open a project window (any project, might need to be OS X instead of iOS)
  3. Use the Debug > Attach To Process menu once it loads to select your target app
  4. Now click the little View Debugging button

    or use the menu again: Debug > View Debugging > Capture View Hierarchy

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.

Mark Bessey

You really can't do this through Core Graphics, since the view hierarchy is entirely a Cocoa concept. You can do this through the Cocoa Scripting Bridge, possibly in combination with the GUI Automation support for Accessibility (here's example code for that).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!