Desktop Input (HID)
模拟键盘/鼠标输入。
在运行 worker 的机器上模拟一次键盘或鼠标操作(输入文本、按键、移动指针或左键单击)。
工作原理
- 检查原生输入模块是否已加载;若未加载,则不执行任何操作直接从
error输出。 - 解析配置。
type(默认keyboard)和action缺失时回退到输入 payload 中的同名键。 - 从
payload.payload(不存在时从payload)读取操作参数text、x、y、key和modifier。若节点配置中没有payload,则payload即为输入数据。 - 键盘:
type输入text;keyTap按下key,可选modifier(字符串或数组)。鼠标:move移动到(x,y),默认为 0;click在当前位置左键单击。 - 从
out返回{ success: true }。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-type-reference",
"label": "Type reference",
"operator_slug": "io.desktop.input",
"operator_version": "1.0.0",
"config": {
"type": "keyboard",
"action": "type",
"payload": {
"text": "{{ $json.reference }}"
}
}
}{
"ok": true,
"data": {
"success": true
},
"port": "out"
}配置
-
typestring 必填 -
actionstring 必填 -
payloadobject 可选 -
{ text, x, y, key, modifier }
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
action - 有效组合:
keyboard+type/keyTap,mouse+move/click。其他组合不执行任何操作,但仍从out输出。 -
payload - 包含操作参数
{ text, x, y, key, modifier }。嵌套的payload.payload优先。click忽略x和y,请先移动指针。
输出端口
out 默认 操作已执行。当 type/action 组合不匹配任何操作时也会触发,此时未模拟任何输入。
数据
{
"success": true
}error 原生输入模块不可用,或操作失败(例如按键名称无效)。
数据
{
"error": "RobotJS Native Module not available in this environment"
}在表达式中
后续节点可通过 $("Desktop Input (HID)").item.json.<路径> 读取此节点输出中的内容(请把 Desktop Input (HID) 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Desktop Input (HID)").item.json.success |
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
RobotJS Native Module not available in this environment | error | 主机无法加载原生输入库(无桌面会话或平台不受支持)。请在有桌面会话的机器上运行该节点。 |
<input library error message> | error | 输入库拒绝了参数,通常是 keyTap 缺少 key 或按键未知。请传入有效的按键名称。 |
输入契约
-
typestring 必填 -
actionstring 必填 -
payloadobject 可选
输出契约
-
successboolean 可选
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.desktop.input",
"name": "Desktop Input (HID)",
"category": "io",
"version": "1.0.0",
"description": "Simulate Keyboard/Mouse input.",
"capabilities": [
"hid",
"keyboard",
"mouse",
"desktop"
],
"config_schema": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"keyboard",
"mouse"
],
"default": "keyboard"
},
"action": {
"type": "string",
"enum": [
"type",
"click",
"move",
"keyTap"
]
},
"payload": {
"type": "object",
"description": "{ text, x, y, key, modifier }"
}
},
"required": [
"type",
"action"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"action": {
"type": "string"
},
"payload": {
"type": "object"
}
},
"required": [
"type",
"action"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Done",
"description": "Input action simulated",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Simulation failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"desktop-agent"
],
"tags": [
"desktop",
"hid"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"keyboard",
"mouse"
],
"default": "keyboard"
},
"action": {
"type": "string",
"enum": [
"type",
"click",
"move",
"keyTap"
]
},
"payload": {
"type": "object",
"description": "{ text, x, y, key, modifier }"
}
},
"required": [
"type",
"action"
]
}{
"type": "object",
"properties": {
"type": {
"type": "string"
},
"action": {
"type": "string"
},
"payload": {
"type": "object"
}
},
"required": [
"type",
"action"
]
}{
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
}[
{
"port_id": "out",
"label": "Done",
"description": "Input action simulated",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Simulation failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 能力
hidkeyboardmousedesktop- 标签
desktophid
说明与限制
- 输入会注入运行 worker 的主机当前桌面会话,由获得焦点的窗口接收。
- 一个节点只执行一个操作。若需操作序列,请串联多个节点(例如先
move,再click,再type)。
已对照编排器代码核实 · 31e874b · 2026-11-26