Feature: Add native region, window and monitor capture to get_screenshot

New Windows clients advertise CLIENT_CAP_SCREEN_REGION and accept a 24-byte
ScreenPreviewReqEx appended to the existing 8-byte preview request, so
get_screenshot can capture a region, a window or a single monitor at 1:1
resolution instead of only the scaled virtual desktop. Successful v2
responses append an optional ScreenCaptureMeta block reporting the source
rect and scale, letting callers map coordinates back for remote input.
Old clients and old servers keep the v1 byte stream unchanged.

The 8192 px per-side bound only applies to native (1:1) capture, where it
guards bitmap memory; scaled captures are unaffected so ultra-wide virtual
desktops (for example triple 4K) still produce thumbnails and previews.
max_width is clamped to [64,1920] as before instead of rejected, matching
the documented schema.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-10 16:34:10 +01:00
1 parent b2c0d81396
commit 235a8a622c
11 files changed
+668 -97

No files matched your search

+69 -2
View File
@@ -463,6 +463,10 @@
"description": "能否截屏(get_screenshot 的前提)",
"type": "boolean"
},
"screenRegion": {
"description": "能否按区域/窗口/显示器原生分辨率截屏(get_screenshot 的 mode=region/window/monitor 前提);仅声明 CLIENT_CAP_SCREEN_REGION 的新 Windows 客户端为 true",
"type": "boolean"
},
"windowInfo": {
"description": "是否支持窗口信息(get_foreground_window、host_list_windows 的坐标/前后台字段、operate_window/host_control_window 的 activate);仅声明 CLIENT_CAP_WINDOW_INFO 的新客户端为 true",
"type": "boolean"
@@ -1044,7 +1048,7 @@
},
{
"name": "get_screenshot",
"description": "截取指定在线主机的一帧屏幕,返回 base64 编码的 JPEG 图片(image 对象含 mimeType/data/width/height)。支持 Windows 与带 X11 桌面的 Linux 客户端(能力位 CLIENT_CAP_SCREEN_PREVIEW),主连接 RPC、一次性返回。",
"description": "截取指定在线主机的一帧画面,返回 base64 编码的 JPEG 图片(image 对象含 mimeType/data/width/height)。支持 Windows 与带 X11 桌面的 Linux 客户端(能力位 CLIENT_CAP_SCREEN_PREVIEW),主连接 RPC、一次性返回。mode 可选 screen(默认,整虚拟桌面)/region(指定矩形)/window(指定 hwnd)/monitor(指定显示器);后三种默认按源尺寸 1:1 原生分辨率抓取(适合 OCR/视觉读字),需要较新的 Windows 客户端(CLIENT_CAP_SCREEN_REGION,否则 -32005),结果在 structuredContent.capture 里回报实际源矩形与缩放比例。",
"gate": null,
"platforms": [
"win",
@@ -1053,12 +1057,49 @@
"impl": "mfc",
"inputSchema": {
"properties": {
"height": {
"description": "region 模式必填:矩形高度(像素,1~8192)。超出虚拟桌面的部分会被裁剪。",
"type": "integer"
},
"hwnd": {
"description": "window 模式必填:窗口句柄(整数或 0x 前缀字符串),取 host_list_windows / get_foreground_window 返回的 hwnd。窗口最小化时无法抓取(返回错误),先 activate/restore。",
"type": [
"integer",
"string"
]
},
"id": {
"description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段",
"type": "string"
},
"max_width": {
"description": "期望图片最大宽度(像素,钳制到 64~1920)。省略或传 0 时沿用 RTT 自适应缩略图档位(最大 1024);传 1920 可拿到接近原分辨率(1080p 源屏即原分辨率,4K 源屏最多 1920),供 AI 视觉/OCR 场景提升清晰度。",
"description": "期望图片最大宽度(像素,钳制到 64~1920)。screen 模式省略或传 0 时沿用 RTT 自适应缩略图档位(最大 1024);region/window/monitor 模式省略/传 0 时按源尺寸 1:1 抓取(原生分辨率),显式传入才等比缩小。",
"type": "integer"
},
"mode": {
"description": "抓取范围,默认 screen。screen=整个虚拟桌面(可缩放);region=指定矩形;window=指定窗口;monitor=指定显示器。region/window/monitor 默认按源尺寸 1:1 抓取(原生分辨率,适合 OCR/视觉读字),只有显式传 max_width 才缩放;这三种需要较新的 Windows 客户端(能力位 CLIENT_CAP_SCREEN_REGION),否则返回 -32005。",
"enum": [
"screen",
"region",
"window",
"monitor"
],
"type": "string"
},
"monitor": {
"description": "monitor 模式:显示器序号,0=主显示器(默认),1..N 为其余显示器(按系统枚举顺序)。序号越界返回错误。",
"type": "integer"
},
"width": {
"description": "region 模式必填:矩形宽度(像素,1~8192)。超出虚拟桌面的部分会被裁剪。",
"type": "integer"
},
"x": {
"description": "region 模式:矩形左上角的虚拟桌面 X 坐标(可为负;多显示器时以虚拟桌面左上角为原点)。省略按 0 处理。",
"type": "integer"
},
"y": {
"description": "region 模式:矩形左上角的虚拟桌面 Y 坐标(可为负)。省略按 0 处理。",
"type": "integer"
}
},
@@ -1069,6 +1110,32 @@
},
"outputSchema": {
"properties": {
"capture": {
"properties": {
"height": {
"type": "integer"
},
"mode": {
"type": "string"
},
"native": {
"type": "boolean"
},
"scale": {
"type": "integer"
},
"width": {
"type": "integer"
},
"x": {
"type": "integer"
},
"y": {
"type": "integer"
}
},
"type": "object"
},
"image": {
"properties": {
"bytes": {