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.
 
 
 
 

42 lines
1.8 KiB

import Cocoa
import ApplicationServices
func inspectApp(named targetName: String) {
guard let app = NSWorkspace.shared.runningApplications.first(where: { $0.localizedName == targetName }) else {
print("App \(targetName) not running")
return
}
print("\n--- Inspecting \(targetName) (PID: \(app.processIdentifier)) ---")
let appElem = AXUIElementCreateApplication(app.processIdentifier)
AXUIElementSetAttributeValue(appElem, "AXEnhancedUserInterface" as CFString, kCFBooleanTrue)
AXUIElementSetAttributeValue(appElem, "AXManualAccessibility" as CFString, kCFBooleanTrue)
var focusedElemObj: CFTypeRef?
let err = AXUIElementCopyAttributeValue(appElem, kAXFocusedUIElementAttribute as CFString, &focusedElemObj)
print("kAXFocusedUIElementAttribute 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 ?? "none")
var rangeObj: CFTypeRef?
let rangeErr = AXUIElementCopyAttributeValue(axElem, kAXSelectedTextRangeAttribute as CFString, &rangeObj)
if rangeErr == .success, let axRange = rangeObj {
var range = CFRange()
if AXValueGetValue(axRange as! AXValue, .cfRange, &range) {
print("Cursor: loc=\(range.location), len=\(range.length)")
}
}
}
}
inspectApp(named: "Telegram")
inspectApp(named: "Obsidian")
inspectApp(named: "firefox")