14 lines
724 B
Swift
14 lines
724 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
|
||
|
|
if pid == 1668 || pid == ProcessInfo.processInfo.processIdentifier {
|
||
|
|
let b = w[kCGWindowBounds as String] as? [String: CGFloat] ?? [:]
|
||
|
|
let name = w[kCGWindowName as String] as? String ?? ""
|
||
|
|
let layer = w[kCGWindowLayer as String] as? Int ?? -1
|
||
|
|
let alpha = w[kCGWindowAlpha as String] as? Double ?? -1
|
||
|
|
print("pid=\(pid) layer=\(layer) alpha=\(alpha) name='\(name)' bounds=\(b)")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|