返回顶部
e

electronElectron桌面自动化

Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include "automate Slack app", "control VS Code", "interact with Discord app", "test this Electron app", "connect to desktop app", or any task requiring automation of a native Electron applica

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
94
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

electron

Electron 应用自动化

使用 agent-browser 自动化任何 Electron 桌面应用。Electron 应用基于 Chromium 构建,并暴露一个 Chrome DevTools 协议(CDP)端口,agent-browser 可以连接到该端口,实现与网页相同的快照-交互工作流程。

核心工作流程

  1. 1. 启动 启用了远程调试的 Electron 应用
  2. 连接 agent-browser 到 CDP 端口
  3. 快照 以发现可交互元素
  4. 交互 使用元素引用
  5. 重新快照 在导航或状态变更后

bash

启动启用了远程调试的 Electron 应用


open -a Slack --args --remote-debugging-port=9222

连接 agent-browser 到应用

agent-browser connect 9222

从这里开始标准工作流程

agent-browser snapshot -i agent-browser click @e5 agent-browser screenshot slack-desktop.png

使用 CDP 启动 Electron 应用

每个 Electron 应用都支持 --remote-debugging-port 标志,因为它是 Chromium 内置的功能。

macOS

bash

Slack


open -a Slack --args --remote-debugging-port=9222

VS Code

open -a Visual Studio Code --args --remote-debugging-port=9223

Discord

open -a Discord --args --remote-debugging-port=9224

Figma

open -a Figma --args --remote-debugging-port=9225

Notion

open -a Notion --args --remote-debugging-port=9226

Spotify

open -a Spotify --args --remote-debugging-port=9227

Linux

bash
slack --remote-debugging-port=9222
code --remote-debugging-port=9223
discord --remote-debugging-port=9224

Windows

bash
C:\Users\%USERNAME%\AppData\Local\slack\slack.exe --remote-debugging-port=9222
C:\Users\%USERNAME%\AppData\Local\Programs\Microsoft VS Code\Code.exe --remote-debugging-port=9223

重要提示: 如果应用已在运行,请先退出,然后使用该标志重新启动。--remote-debugging-port 标志必须在启动时存在。

连接

bash

连接到特定端口


agent-browser connect 9222

或者在每个命令上使用 --cdp

agent-browser --cdp 9222 snapshot -i

自动发现正在运行的基于 Chromium 的应用

agent-browser --auto-connect snapshot -i

执行 connect 后,所有后续命令都会针对已连接的应用,无需使用 --cdp。

标签页管理

Electron 应用通常有多个窗口或 webview。使用标签页命令列出并在它们之间切换:

bash

列出所有可用目标(窗口、webview 等)


agent-browser tab

按索引切换到特定标签页

agent-browser tab 2

按 URL 模式切换

agent-browser tab --url settings

Webview 支持

Electron 元素会被自动发现,并且可以像普通页面一样进行控制。Webview 在标签页列表中作为独立目标出现,类型为 webview:

bash

连接到正在运行的 Electron 应用


agent-browser connect 9222

列出目标——webview 与页面一起出现

agent-browser tab

示例输出:

0: [page] Slack - 主窗口 https://app.slack.com/

1: [webview] 嵌入内容 https://example.com/widget

切换到 webview

agent-browser tab 1

正常与 webview 交互

agent-browser snapshot -i agent-browser click @e3 agent-browser screenshot webview.png

注意: Webview 支持通过原始 CDP 连接工作。

常见模式

检查并导航应用

bash
open -a Slack --args --remote-debugging-port=9222
sleep 3 # 等待应用启动
agent-browser connect 9222
agent-browser snapshot -i

读取快照输出以识别 UI 元素


agent-browser click @e10 # 导航到某个部分
agent-browser snapshot -i # 导航后重新快照

截取桌面应用截图

bash
agent-browser connect 9222
agent-browser screenshot app-state.png
agent-browser screenshot --full full-app.png
agent-browser screenshot --annotate annotated-app.png

从桌面应用提取数据

bash
agent-browser connect 9222
agent-browser snapshot -i
agent-browser get text @e5
agent-browser snapshot --json > app-state.json

在桌面应用中填写表单

bash
agent-browser connect 9222
agent-browser snapshot -i
agent-browser fill @e3 搜索查询
agent-browser press Enter
agent-browser wait 1000
agent-browser snapshot -i

同时运行多个应用

使用命名会话同时控制多个 Electron 应用:

bash

连接到 Slack


agent-browser --session slack connect 9222

连接到 VS Code

agent-browser --session vscode connect 9223

独立与每个应用交互

agent-browser --session slack snapshot -i agent-browser --session vscode snapshot -i

配色方案

通过 CDP 连接时的默认配色方案可能是 light。要保留深色模式:

bash
agent-browser connect 9222
agent-browser --color-scheme dark snapshot -i

或者全局设置:

bash
AGENTBROWSERCOLOR_SCHEME=dark agent-browser connect 9222

故障排除

连接被拒绝 或 无法连接

  • - 确保应用已使用 --remote-debugging-port=NNNN 启动
  • 如果应用已在运行,请退出并使用该标志重新启动
  • 检查端口是否被其他进程占用:lsof -i :9222

应用启动但连接失败

  • - 启动后等待几秒再连接(sleep 3)
  • 某些应用需要时间来初始化其 webview

快照中未显示元素

  • - 应用可能使用了多个 webview。使用 agent-browser tab 列出目标并切换到正确的目标
  • 使用 agent-browser snapshot -i -C 包含光标交互元素(带有 onclick 处理程序的 div)

无法在输入字段中输入

  • - 尝试使用 agent-browser keyboard type text 在当前焦点处输入,无需选择器
  • 某些 Electron 应用使用自定义输入组件;使用 agent-browser keyboard inserttext text 绕过按键事件

支持的应用

任何基于 Electron 构建的应用都可以工作,包括:

  • - 通讯: Slack、Discord、Microsoft Teams、Signal、Telegram Desktop
  • 开发: VS Code、GitHub Desktop、Postman、Insomnia
  • 设计: Figma、Notion、Obsidian
  • 媒体: Spotify、Tidal
  • 生产力: Todoist、Linear、1Password

如果应用是使用 Electron 构建的,它支持 --remote-debugging-port,并且可以使用 agent-browser 进行自动化。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 daxiang-electron-1775909521 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 daxiang-electron-1775909521 技能

通过命令行安装

skillhub install daxiang-electron-1775909521

下载

⬇ 下载 electron v1.0.0(免费)

文件大小: 3.1 KB | 发布时间: 2026-4-12 09:40

v1.0.0 最新 2026-4-12 09:40
Initial release of Electron app automation skill:

- Automate native Electron desktop apps (like VS Code, Slack, Discord, Figma, Notion, Spotify) using agent-browser via Chrome DevTools Protocol (CDP)
- Includes step-by-step instructions for launching apps with debugging enabled on macOS, Linux, and Windows
- Supports snapshotting, interacting, extracting data, filling forms, and taking screenshots in Electron apps
- Allows control of multiple apps and windows/webviews simultaneously
- Provides troubleshooting guidance and common automation patterns

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部