Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 935
Suyash Patel Avatar asked Nov 02 '15 07:11

Suyash Patel


1 Answers

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 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.

like image 173
natevw Avatar answered Nov 01 '22 14:11

natevw