Soniox Mobile to Mac - Real-time Voice Dictation & Remote Input Control
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
1.8 KiB

import Cocoa
import ApplicationServices
func inspect() {
guard let frontApp = NSWorkspace.shared.frontmostApplication else {
print("No front app")
return
}
print("Front App:", frontApp.localizedName ?? "", "PID:", frontApp.processIdentifier)
let trusted = AXIsProcessTrusted()
print("AXIsProcessTrusted:", trusted)
let appElem = AXUIElementCreateApplication(frontApp.processIdentifier)
var focusedElemObj: CFTypeRef?
let err = AXUIElementCopyAttributeValue(appElem, kAXFocusedUIElementAttribute as CFString, &focusedElemObj)
print("kAXFocusedUIElement error:", err.rawValue)
if err == .success, let elem = focusedElemObj {
let axElem = elem as! AXUIElement
var roleObj: CFTypeRef?
AXUIElementCopyAttributeValue(axElem, kAXRoleAttribute as CFString, &roleObj)
print("Role:", roleObj ?? "none")
var valObj: CFTypeRef?
let valErr = AXUIElementCopyAttributeValue(axElem, kAXValueAttribute as CFString, &valObj)
print("Value err:", valErr.rawValue, "Value:", valObj ?? "nil")
var selectedTextObj: CFTypeRef?
let selTxtErr = AXUIElementCopyAttributeValue(axElem, kAXSelectedTextAttribute as CFString, &selectedTextObj)
print("SelectedText err:", selTxtErr.rawValue, "SelectedText:", selectedTextObj ?? "nil")
var rangeObj: CFTypeRef?
let rangeErr = AXUIElementCopyAttributeValue(axElem, kAXSelectedTextRangeAttribute as CFString, &rangeObj)
print("Range err:", rangeErr.rawValue)
if rangeErr == .success, let axRange = rangeObj {
var range = CFRange()
if AXValueGetValue(axRange as! AXValue, .cfRange, &range) {
print("CFRange: loc=\(range.location), len=\(range.length)")
}
}
}
}
inspect()