let options = CGWindowListOption(arrayLiteral: CGWindowListOption.excludeDesktopElements, CGWindowListOption.optionOnScreenOnly)
let windowListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0))
guard let infoList = windowListInfo as? [[String: AnyObject]] else { return }
if let window = infoList.first(where: { ($0["kCGWindowOwnerName"] as? String) == "WeChat"}), let pid = window["kCGWindowOwnerPID"] as? Int32 {
let app = NSRunningApplication(processIdentifier: pid)
app?.activate(options: .activateIgnoringOtherApps)
}
Mac OS 如何让其他应用窗口活跃并置前
于 2022-02-21 16:59:51 首次发布