Initial commit
This commit is contained in:
commit
d5c932d8e1
710 changed files with 50282 additions and 0 deletions
22
.tmp_axprobe/capwin.swift
Executable file
22
.tmp_axprobe/capwin.swift
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
import Cocoa
|
||||
let pid = pid_t(CommandLine.arguments[1])!
|
||||
let out = CommandLine.arguments[2]
|
||||
guard let wins = CGWindowListCopyWindowInfo([.optionOnScreenOnly], kCGNullWindowID) as? [[String: Any]] else { exit(1) }
|
||||
for w in wins {
|
||||
if (w[kCGWindowOwnerPID as String] as? Int) == pid,
|
||||
(w[kCGWindowLayer as String] as? Int) == 0,
|
||||
let wid = w[kCGWindowNumber as String] as? Int,
|
||||
let bd = w[kCGWindowBounds as String] as? [String: Any],
|
||||
(bd["Width"] as! Double) > 400 {
|
||||
if let img = CGWindowListCreateImage(.null, .optionIncludingWindow, CGWindowID(wid), [.boundsIgnoreFraming]) {
|
||||
let url = URL(fileURLWithPath: out)
|
||||
if let dest = CGImageDestinationCreateWithURL(url as CFURL, "public.png" as CFString, 1, nil) {
|
||||
CGImageDestinationAddImage(dest, img, nil)
|
||||
CGImageDestinationFinalize(dest)
|
||||
print("saved \(out) size=\(img.width)x\(img.height)")
|
||||
}
|
||||
} else { print("capture failed") }
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
print("no window found")
|
||||
Loading…
Reference in a new issue