Initial commit
This commit is contained in:
commit
d5c932d8e1
710 changed files with 50282 additions and 0 deletions
31
.tmp_axprobe/hover.swift
Executable file
31
.tmp_axprobe/hover.swift
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
import Cocoa
|
||||
// move mouse to (849,707) global logical, no click
|
||||
let move = CGEvent(mouseEventSource: nil, mouseType: .mouseMoved, mouseCursorPosition: CGPoint(x: 849, y: 707), mouseButton: .left)
|
||||
move?.post(tap: .cghidEventTap)
|
||||
usleep(400_000)
|
||||
// query AX element at that point for pid 1668
|
||||
let app = AXUIElementCreateApplication(1668)
|
||||
var el: AXUIElement?
|
||||
let err = AXUIElementCopyElementAtPosition(app, 849, 707, &el)
|
||||
print("AXUIElementCopyElementAtPosition err=\(err.rawValue)")
|
||||
if let el = el {
|
||||
func s(_ a: String) -> String {
|
||||
var v: CFTypeRef?
|
||||
if AXUIElementCopyAttributeValue(el, a as CFString, &v) == .success, let st = v as? String { return st.replacingOccurrences(of: "\n", with: "⏎") }
|
||||
return ""
|
||||
}
|
||||
print("role=\(s(kAXRoleAttribute)) title=\(s(kAXTitleAttribute)) value=\(String(s(kAXValueAttribute).prefix(80))) desc=\(s(kAXDescriptionAttribute)) url=\(s(kAXURLAttribute))")
|
||||
// walk up parents a few levels
|
||||
var cur = el
|
||||
for _ in 0..<5 {
|
||||
var p: CFTypeRef?
|
||||
guard AXUIElementCopyAttributeValue(cur, kAXParentAttribute as CFString, &p) == .success, let pp = p else { break }
|
||||
cur = pp as! AXUIElement
|
||||
var v: CFTypeRef?
|
||||
var role = "", val = ""
|
||||
if AXUIElementCopyAttributeValue(cur, kAXRoleAttribute as CFString, &v) == .success { role = (v as? String) ?? "" }
|
||||
v = nil
|
||||
if AXUIElementCopyAttributeValue(cur, kAXValueAttribute as CFString, &v) == .success { val = String(((v as? String) ?? "").prefix(50)).replacingOccurrences(of: "\n", with: "⏎") }
|
||||
print(" parent role=\(role) val=\(val)")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue