Install
openclaw skills install macscreenshotCapture macOS screenshots for the whole screen, a specific app window, or a precisely targeted desktop window using built-in system tools. Use when the user asks to screenshot the desktop, a frontmost app, a WeChat/Weixin window, a Chrome window, or to locate a macOS window by keyword and capture it. Prefer the built-in screencapture command and CoreGraphics window enumeration via inline Swift. If required capabilities are missing, tell the user exactly which macOS permissions to enable; if Swift tooling is unavailable, tell the user how to install Xcode Command Line Tools manually.
openclaw skills install macscreenshotCapture screenshots on macOS with built-in tools only.
screencapture -x <output>.owner and name, matching keywords like weixin, wechat, or the app name the user gave.sharing is 1.screencapture -x -l <windowId> <output>.Prefer the bundled script when available:
scripts/capture-window-by-keyword.sh <keyword> [output_path]
scripts/capture-window-by-keyword.sh --list <keyword>
scripts/capture-window-by-keyword.sh --index <n> <keyword> [output_path]
Examples:
scripts/capture-window-by-keyword.sh wechat
scripts/capture-window-by-keyword.sh --list wechat
scripts/capture-window-by-keyword.sh --index 2 wechat
The script:
owner and nameweixin -> wechat, wxsharing = 1screencapture -x -l <windowId>Use this exact pattern to locate candidate windows:
swift - <<'SWIFT'
import CoreGraphics
import Foundation
let options = CGWindowListOption(arrayLiteral: .optionOnScreenOnly, .excludeDesktopElements)
let windows = (CGWindowListCopyWindowInfo(options, kCGNullWindowID) as? [[String: Any]]) ?? []
let matches = windows.compactMap { w -> [String: Any]? in
let owner = (w[kCGWindowOwnerName as String] as? String) ?? ""
let name = (w[kCGWindowName as String] as? String) ?? ""
let low = (owner + " " + name).lowercased()
guard low.contains("weixin") || low.contains("wechat") else { return nil }
return [
"id": w[kCGWindowNumber as String] ?? "",
"owner": owner,
"name": name,
"sharing": w[kCGWindowSharingState as String] ?? "",
"bounds": w[kCGWindowBounds as String] ?? ""
]
}
let data = try! JSONSerialization.data(withJSONObject: matches, options: [.prettyPrinted])
print(String(data: data, encoding: .utf8)!)
SWIFT
Typical success indicators:
owner or name matches the requested app/windowid is presentsharing = 1Then capture the window:
screencapture -x -l <windowId> <output.png>
Quartz; it may not be installed.System Events window attributes for window IDs; some apps do not expose AXWindowNumber reliably.CGWindowListCopyWindowInfo is the most reliable built-in approach on macOS.screencapture -l <windowId> is a true system window capture, not a cropped full-screen image.screencapture works for full screen but not for a windowCheck whether the enumerated target has sharing = 1. If not, tell the user the app/window is not currently shareable for window capture and ask them to bring it to the front and try again.
System Events says assistive access is not allowedDo not rely on that path. Prefer the Swift + CoreGraphics method. If the user still wants UI-structure inspection, tell them to enable:
openclaw-gateway, Terminal, or the active terminal hostTell the user to enable:
swift is not foundTell the user to install Xcode Command Line Tools manually:
xcode-select --install
If that fails or they want the GUI path, tell them to install Xcode from the App Store or re-run the command after opening Software Update.
Prefer saving screenshots into a workspace subdirectory like:
screenshots/captures/Use descriptive filenames with timestamps when the user may request multiple captures.
Treat screenshots as potentially sensitive local artifacts.
When a screenshot request comes from a chat surface: