zhuyuan-ice-gl-zy001/.tmp_axprobe/hit2.swift
2026-08-20 00:01:53 +08:00

15 lines
720 B
Swift
Executable file

import Cocoa
let px = Float(CommandLine.arguments[1])!, py = Float(CommandLine.arguments[2])!
let sw = AXUIElementCreateSystemWide()
var el: AXUIElement?
guard AXUIElementCopyElementAtPosition(sw, px, py, &el) == .success, let el else { print("no hit"); exit(0) }
func attr(_ a: String) -> String {
var v: CFTypeRef?
guard AXUIElementCopyAttributeValue(el, a as CFString, &v) == .success, let v else { return "<none>" }
return String(describing: v).prefix(120).description
}
print("role=\(attr(kAXRoleAttribute))")
print("pos=\(attr(kAXPositionAttribute)) size=\(attr(kAXSizeAttribute))")
print("desc=\(attr(kAXDescriptionAttribute))")
print("url=\(attr("AXURL"))")
print("actions=\(attr("AXActionNames"))")