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

17 lines
756 B
Swift
Executable file

import Cocoa
let app = NSRunningApplication(processIdentifier: 1668)
app?.activate(options: [.activateIgnoringOtherApps])
usleep(300_000)
let axApp = AXUIElementCreateApplication(1668)
var windowsRef: CFTypeRef?
AXUIElementCopyAttributeValue(axApp, kAXWindowsAttribute as CFString, &windowsRef)
if let wins = windowsRef as? [AXUIElement] {
for (i, w) in wins.enumerated() {
var tRef: CFTypeRef?
AXUIElementCopyAttributeValue(w, kAXTitleAttribute as CFString, &tRef)
let t = (tRef as? String) ?? "?"
let r = AXUIElementPerformAction(w, kAXRaiseAction as CFString)
print("window \(i) title=\(t) raise=\(r.rawValue)")
}
}
print("frontmost now: \(NSWorkspace.shared.frontmostApplication?.localizedName ?? "?")")