File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,20 @@ public extension AXUIElement {
8484 var isHidden : Bool {
8585 ( try ? copyValue ( key: kAXHiddenAttribute) ) ?? false
8686 }
87+
88+ var debugDescription : String {
89+ " < \( title) > < \( description) > ( \( role) : \( roleDescription) ) [ \( identifier) ] \( rect ?? . zero) \( children. count) children "
90+ }
91+
92+ var debugEnumerateChildren : String {
93+ var result = " > " + debugDescription + " \n "
94+ result += children. map {
95+ $0. debugEnumerateChildren. split ( separator: " \n " )
96+ . map { " " + $0 }
97+ . joined ( separator: " \n " )
98+ } . joined ( separator: " \n " )
99+ return result
100+ }
87101}
88102
89103// MARK: - Rect
@@ -137,6 +151,15 @@ public extension AXUIElement {
137151 var isFullScreen : Bool {
138152 ( try ? copyValue ( key: " AXFullScreen " ) ) ?? false
139153 }
154+
155+ var windowID : CGWindowID ? {
156+ var identifier : CGWindowID = 0
157+ let error = AXUIElementGetWindow ( self , & identifier)
158+ if error == . success {
159+ return identifier
160+ }
161+ return nil
162+ }
140163
141164 var isFrontmost : Bool {
142165 get {
Original file line number Diff line number Diff line change 1+ import AppKit
2+
3+ /// AXError _AXUIElementGetWindow(AXUIElementRef element, uint32_t *identifier);
4+ @_silgen_name ( " _AXUIElementGetWindow " ) @discardableResult
5+ func AXUIElementGetWindow(
6+ _ element: AXUIElement ,
7+ _ identifier: UnsafeMutablePointer < CGWindowID >
8+ ) -> AXError
You can’t perform that action at this time.
0 commit comments