from __future__ import annotations from pathlib import Path from typing import Any from ... import windows_automation from ..context import WorkflowContext from ..registry import control_ports, field_def, register_node def screenshot_node(node: dict[str, Any], inputs: dict[str, Any], context: WorkflowContext) -> dict[str, Any]: save_path = inputs.get("save_path", node.get("params", {}).get("save_path")) result = windows_automation.take_screenshot(str(Path(save_path)) if save_path else None, include_base64=False) if result.get("path"): context.runtime["current_screenshot_path"] = result["path"] return result register_node( { "type": "screen.screenshot", "category": "screen", "label": "屏幕截图", "params": {"save_path": field_def("text", "保存路径")}, "inputs": {"save_path": field_def("string", "保存路径")}, "outputs": { "path": {"type": "string", "label": "图片路径"}, "width": {"type": "number", "label": "宽度"}, "height": {"type": "number", "label": "高度"}, }, "control_ports": control_ports(), }, screenshot_node, )