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.
how to traverse window/view hierarchy of other application in macOS?
1.7k views Asked by Suyash Patel At
2
There are 2 answers
0
natevw
On
This is now possible via the View Debugging features of Xcode. To use this:
- Start the target app running as you normally would
- Launch Xcode, and open a project window (any project, might need to be OS X instead of iOS)
- Use the Debug > Attach To Process menu once it loads to select your target app
- 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.
Related Questions in MACOS
- Error installing Nativescript on Mac M2 Sonoma 14.4.1
- macOS - Most secure way of a GUI SUDO_ASKPASS
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Why does Hugo generate different taxonomy-related HTML on different OS's?
- ZSH function parameters conundrum
- how to make read only file/directory in Mac writable
- macOS BigSur - Unable to run bundled php version or brew php 8
- 9 Digit Addresses in Hexadecimal System in MacOS
- MacOS Bash-Script: while read p and echo
- How to make a range for tail rows on a categorized table in Numbers with JXA scripts?
- Cannot build a basic project with curl on Mac (M2) for Raspberry Pi Pico
- How to recover deleted files from create vite react project
- Can't run built SFML project from Xcode template
- React Native - RealmJS - Linker command failed with exit code 1
- How can I manually add a keyboard shortcut to a Shortcut Action Service directly via the system files, without going through the System Prefs GUI?
Related Questions in COCOA
- In what context can we use an unqualified #selector() expression in Swift?
- How can I trigger macOS system gamepad API based on a value received from iOS app through core bluetooth
- Using sort descriptors in Outline View
- NSTableView to NSOutlineView Drag & Drop not accepting drop
- How to remove horizontal line in bottom of section NSTableView?
- CGSRegionRef: How is an arbitrary region represented as union of rects?
- Listen for Touch Events on MacOS (Trackpad)
- Window "yanks" when moving
- Writing NSFilePromiseProviders to pasteboard blocks app on quit
- Basic ImGui program doesn't render, leaks memory and crashes
- NSTokenField suggestion using context menu in swift
- How to link multiple text views to a single text storage in TextKit 2
- I would like to know why I’m not getting IBOutlets connected in an App’s window
- How to make a custom event loop in Cocoa?
- Why is restoreWindow(withIdentifier:state:) called after applicationDidFinishLaunching(_:)?
Related Questions in CORE-GRAPHICS
- CGSRegionRef: How is an arbitrary region represented as union of rects?
- Black image when rendering PDF to image with UIGraphicsImageRendererFormat
- Draw CGContext into Canvas in SwiftUI
- Add rounded corners + transparency background from import video (.mp4) to exported video (.mov) in Swift
- How to render content of CALayer and sync with it in real-time
- How to create a CGColor in an index based CGColorSpace?
- What is the way to extract the value of an Image pixel given that a GCPoint value is available?
- Xcode analyzer is showing leak for CGPathRef when it's in a class instance method?
- QR Images not rendered on Widget after iOS 17
- How to correctly position graphic after flipping it
- How to set antialiasing on or off in a SwiftUI Canvas
- How to get the name and window id of the current in focus window on macOS and change its position in rust?
- How to Intercept and Monitor Volume and Screen Brightness Function Keys on macOS?
- Why are sampled colors from a CGImage different depending on whether it's a thumbnail?
- CleanupRecodeProperties:3604 Error Message Meaning
Related Questions in NSWINDOW
- How can I create a new Main Window?
- How track a NSWindow's onActiveSpace property
- AppKit and NSWindow are inaccessable in VisionOS project
- NSView as child of NSWindow.contentView lose interaction
- sharingType property for NSWindow works but property value is not updated correctly
- Reproduce the exact background effect of macOS control center items in the status bar
- TextField shortcuts in NSWindow created programmatically vs SwiftUI
- Animating NSWindow based on SwiftUI View Transition
- Make one of multiple NSWindow persistent across all the windows, including fullscreen windows
- How to restore window frame with multiple screens
- How can I Hide the "Move Window to Left Side of Screen" option of window's resize button on Macos programmatically?
- How to enable clicks through window toolbar
- 'unrecognized selector' error happens when creating a subclass that inherits from NSWindow
- Autosaving NSDocument memory leak with NSWindow and NSToolbar - NSDocumentTitlebarPopoverViewController leaks
- How do I reset view frame origin, width & height when returning from a navigation destination
Related Questions in APP-INSPECTION
- regex in query parameter in Network Inspector Rule
- CoroutineWorker not showing up correctly in Android Studio's "Background Task Inspector"
- Network inspector doesn't replace status code - Android Studio Flamingo
- Unable to find [App Inspection] option in Android Studio under View <Tool Window<
- Problem with Android Studio App Inspector
- Issue while exporting data Room database from App Inspection : For security reasons offline mode is disabled
- how to traverse window/view hierarchy of other application in macOS?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
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).