14 lines
645 B
Swift
14 lines
645 B
Swift
|
|
import Cocoa
|
||
|
|
let opts: CGWindowListOption = [.optionOnScreenOnly, .excludeDesktopElements]
|
||
|
|
if let list = CGWindowListCopyWindowInfo(opts, kCGNullWindowID) as? [[String: Any]] {
|
||
|
|
for w in list {
|
||
|
|
let pid = w[kCGWindowOwnerPID as String] as? Int ?? -1
|
||
|
|
let owner = w[kCGWindowOwnerName as String] as? String ?? "?"
|
||
|
|
let name = w[kCGWindowName as String] as? String ?? ""
|
||
|
|
let b = w[kCGWindowBounds as String] as? [String: CGFloat] ?? [:]
|
||
|
|
let layer = w[kCGWindowLayer as String] as? Int ?? -1
|
||
|
|
if layer == 0 {
|
||
|
|
print("pid=\(pid) owner=\(owner) name='\(name)' bounds=\(b)")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|