import Cocoa let px = Double(CommandLine.arguments[1])!, py = Double(CommandLine.arguments[2])! if let wins = CGWindowListCopyWindowInfo([.optionAll], kCGNullWindowID) as? [[String: Any]] { for w in wins { let name = w[kCGWindowOwnerName as String] as? String ?? "?" let title = w[kCGWindowName as String] as? String ?? "" let layer = w[kCGWindowLayer as String] as? Int ?? -1 let pid = w[kCGWindowOwnerPID as String] as? Int ?? -1 var b = CGRect.null if let d = w[kCGWindowBounds as String] as? [String: Any] { b = CGRect(x: d["X"] as! Double, y: d["Y"] as! Double, width: d["Width"] as! Double, height: d["Height"] as! Double) } let onTop = w[kCGWindowIsOnscreen as String] as? Bool ?? false let contains = b.contains(CGPoint(x: px, y: py)) print("layer=\(layer) onScreen=\(onTop) pid=\(pid) owner=\(name) title=\(title) bounds=\(b) containsPoint=\(contains)") } }