返回顶部
d

desktop-control桌面控制

Control the desktop via CUA computer server API running on port 8000

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

desktop-control

通过CUA服务器控制桌面

此技能允许OpenClaw使用CUA计算机服务器API控制桌面。

⚠️ 安全须知

此技能需要安装并运行一个第三方服务器(cua-computer-sdk),该服务器对您的桌面拥有完全控制权。

使用此技能前请注意:

  • - 该服务器可以模拟键盘、鼠标操作并截取屏幕截图
  • 仅可在您信任所有用户和进程的系统上运行
  • 服务器以您的用户权限运行(无需sudo/管理员权限)
  • 默认情况下,仅可从本地主机访问(本地使用安全)

前提条件

  • - 系统已安装Python 3.12+
  • CUA计算机服务器在8000端口运行(参见下方安装说明)
  • 仅可访问localhost:8000(不建议暴露到网络)

安装

推荐:临时会话(最安全)

仅在需要时运行服务器,并在可监控的终端中运行:

bash

安装计算机SDK(官方CUA包)


pip install cua-computer-sdk

验证包(可选但推荐)

pip show cua-computer-sdk # 检查发布者和版本

临时运行(按Ctrl+C停止)

cua-server start --port 8000 --bind 127.0.0.1

在另一个终端中,验证它仅在本地运行

curl http://localhost:8000/status netstat -an | grep 8000 # 应显示127.0.0.1:8000

这是最安全的方法 - 服务器仅在您明确启动时运行,关闭终端时停止。

备选:从源码安装

为保持透明,您可以审查并从源码运行:

bash

先克隆并审查代码


git clone https://github.com/trycua/cua-computer-server
cd cua-computer-server

运行前审查代码

ls -la cat requirements.txt # 检查依赖

安装并运行

pip install -r requirements.txt python -m cua_server --port 8000 --bind 127.0.0.1

运行服务器

选项1:手动启动(推荐)
bash

在前台启动 - 您可以看到它在做什么


cua-server start --port 8000

完成后按Ctrl+C停止

选项2:后台进程(临时)
bash

仅在当前会话中后台运行


cua-server start --port 8000 &

记下进程ID

echo 服务器PID: $!

完成后停止

kill

注意: 此技能不需要持久化/系统服务安装。推荐在需要时临时运行服务器。

范围与限制

此技能:

  • - ✅ 在服务器运行时控制您的桌面
  • ✅ 以您的用户权限运行(无需管理员/sudo权限)
  • ✅ 默认仅可从本地主机访问

安全最佳实践

  1. 1. 临时运行:仅在需要时启动服务器,完成后停止
  2. 仅限本地主机:保持默认绑定到127.0.0.1
  3. 不暴露网络:除非绝对必要,避免使用--bind 0.0.0.0
  4. 监控活动:在前台运行以查看执行的命令
  5. 有限范围:服务器只能执行您的用户账户可以执行的操作

快速测试

启动服务器后,验证其工作状态:

bash

简单健康检查


curl http://localhost:8000/status

应返回:{status: ok}

截取屏幕截图(安全测试)

curl -X POST http://localhost:8000/cmd \ -H Content-Type: application/json \ -d {command: screenshot} \ -o screenshot.json

如果成功,您将获得包含base64图像数据的JSON响应

故障排除

端口已被占用:
bash

检查什么在使用8000端口


lsof -i :8000 # macOS/Linux
netstat -ano | findstr :8000 # Windows

解决方案:使用不同端口

cua-server start --port 8001

权限被拒绝(Linux):
bash

您可能需要将用户添加到input组以控制键盘/鼠标


sudo usermod -a -G input $USER

注销并重新登录以使更改生效

未找到显示(Linux):
bash

检查您的显示变量


echo $DISPLAY

明确设置

DISPLAY=:0 cua-server start --port 8000

服务器无响应:
bash

检查进程是否在运行


ps aux | grep cua-server # Linux/macOS
tasklist | findstr cua-server # Windows

尝试在前台运行以查看错误

cua-server start --port 8000 --debug

可用命令

截取屏幕截图

捕获当前屏幕:
bash
curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: screenshot} \
| jq -r .result.base64 \
| base64 -d > screenshot.png

在坐标处点击

在特定x,y坐标处点击:
bash

在1280x720屏幕中心点击


curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: left_click, params: {x: 640, y: 360}}

右键点击

bash curl -X POST http://localhost:8000/cmd \ -H Content-Type: application/json \ -d {command: right_click, params: {x: 640, y: 360}}

双击

bash curl -X POST http://localhost:8000/cmd \ -H Content-Type: application/json \ -d {command: double_click, params: {x: 640, y: 360}}

输入文本

在当前光标位置输入文本:
bash
curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: type_text, params: {text: Hello, World!}}

按下快捷键

按下组合键:
bash

Ctrl+C


curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: hotkey, params: {keys: [ctrl, c]}}

Ctrl+Alt+T(打开终端)

curl -X POST http://localhost:8000/cmd \ -H Content-Type: application/json \ -d {command: hotkey, params: {keys: [ctrl, alt, t]}}

按下单个键

按下单个键:
bash

按下回车


curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: press_key, params: {key: enter}}

按下Esc

curl -X POST http://localhost:8000/cmd \ -H Content-Type: application/json \ -d {command: press_key, params: {key: escape}}

移动光标

将光标移动到特定位置:
bash
curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: move_cursor, params: {x: 100, y: 200}}

滚动

向上或向下滚动:
bash

向下滚动3个单位


curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: scroll_direction, params: {direction: down, amount: 3}}

向上滚动5个单位

curl -X POST http://localhost:8000/cmd \ -H Content-Type: application/json \ -d {command: scroll_direction, params: {direction: up, amount: 5}}

启动应用程序

按名称启动应用程序:
bash

启动Firefox


curl -X POST http://localhost:8000/cmd \
-H Content-Type: application/json \
-d {command: launch, params: {app: firefox}}

启动终端

curl -X POST http://localhost:8000/cmd \ -H Content-Type: application/json \ -d {command: launch, params: {app: xfce4-terminal}}

打开文件或URL

使用默认应用程序打开文件或URL

标签

skill ai

通过对话安装

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

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 gui-automation-1776160574 技能

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

设置 SkillHub 为我的优先技能安装源,然后帮我安装 gui-automation-1776160574 技能

通过命令行安装

skillhub install gui-automation-1776160574

下载

⬇ 下载 desktop-control v1.0.1(免费)

文件大小: 4.19 KB | 发布时间: 2026-4-15 13:27

v1.0.1 最新 2026-4-15 13:27
Version 1.0.1

- Improved security guidance and best practices prominently in the documentation.
- Clarified that running the Cua server as a temporary foreground process is recommended.
- Reduced instructions about persistent/system/background installation; now emphasizes temporary/manual use.
- Simplified installation and troubleshooting steps for easier and safer onboarding.
- Expanded and reorganized documentation warnings about the server’s capabilities and risks.

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

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

p2p_official_large
返回顶部