微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🖱️

跨平台桌面自动化,安全可控

Desktop automation ultra · v2.0.0
效率 安全 A 级 作者 jordaneparis 公开目录收录
1.2k 下载 0 安装 2.4k 收藏 17 浏览

简介

跨平台桌面自动化技能,支持键鼠模拟、截图OCR、图像识别与宏录制,内置安全模式与干运行测试,适合批量重复任务自动化。

原始描述

Automate comprehensive desktop tasks on Windows/macOS/Linux with safe, logged mouse, keyboard, OCR, image recognition, macro recording, and replay features.

通过你的 Agent 添加

点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。

或者手动安装

Claude Codeunzip -o skill.zip -d ~/.claude/skills/desktop-automation-ultra/
其它 Agent解压到它自己的 skills 目录,目录名用 desktop-automation-ultra

包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。 技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。

中文使用说明 来自收录源

核心用法

Desktop Automation Skill v2.0 是一款基于 Python/pyautogui 的跨平台桌面自动化工具,支持 Windows/macOS/Linux 三大系统。核心功能涵盖:

键鼠自动化:模拟点击、拖拽、滚动、键盘输入,支持自定义间隔与按键组合;视觉识别:集成 OpenCV 模板匹配实现图像定位,支持多尺度检测;OCR 文本提取:基于 Tesseract 识别屏幕文字,支持多语言(默认法语 fra);宏录制与回放:自动记录用户操作序列,支持鼠标移动防抖压缩,JSON 格式存储;窗口管理:获取/激活窗口、枚举窗口列表;剪贴板操作:读写剪贴板内容。

使用流程:安装依赖 → 放置技能目录 → 重启 OpenClaw → 通过 YAML 调用各项 action,所有操作均支持 dry_run=true 预演测试。

显著优点

  1. 零 API 依赖:直接操控系统输入层,无需目标应用开放接口,普适性极强
  2. 安全设计完善:默认开启 safe mode,拦截 rm/sudo/系统目录等危险操作;全量审计日志;干运行模式杜绝误操作
  3. 跨平台一致:同一套 YAML 语法通吃三大桌面系统
  4. 宏智能优化:鼠标移动防抖机制显著压缩宏体积,保留关键节点
  5. 扩展性佳:模块化架构(actions/image_recognition/ocr_engine/macro_player/safety_manager),便于二次开发

潜在缺点与局限性

  • OCR 质量依赖环境:Tesseract 安装复杂,识别准确率受字体、对比度、分辨率影响
  • 图像识别 fragile:模板匹配对 UI 变化敏感,分辨率/主题更换可能导致定位失败
  • 无原生应用感知:基于坐标和像素的自动化,无法像 Accessibility API 那样理解控件语义
  • 性能瓶颈:纯 Python + 截图轮询,高频场景 CPU 占用较高
  • 宏可移植性差:绝对坐标录制在不同分辨率设备间无法通用

适合人群

  • 需要批量处理重复性桌面操作的技术人员(数据录入、表单填写、测试人员)
  • 无编程 API 的老旧系统自动化改造
  • 个人效率工具爱好者,愿意接受一定的维护成本

常规风险

风险类型 说明 缓解措施
隐私泄露 全键鼠事件捕获可能记录密码/敏感信息 明确警告用户录制时避开敏感输入,宏文件加密存储
误操作破坏 自动化执行系统命令或删除文件 safe mode 默认拦截危险模式,dry_run 强制测试
依赖漏洞 pyautogui/OpenCV/Tesseract 供应链风险 定期更新依赖,隔离运行环境
权限提升 需系统级输入权限,可能被恶意利用 最小权限原则,审计日志全量留存
宏注入攻击 篡改 JSON 宏文件植入恶意操作 宏文件完整性校验,来源白名单

技能正文

Desktop Automation Skill v2.0

License: MIT OpenClaw

Complete desktop automation for Windows/macOS/Linux. Zero-error edition.


⚠️ Privacy & Security

CRITICAL: This skill captures ALL keyboard and mouse events.

  • NEVER record while entering passwords, credit cards, or secrets
  • Recorded macros are stored as JSON in recorded_macro/ directory
  • Always use dry_run=true to test before actual execution
  • Store macros in secure locations only
  • Enable safe mode by default (it is)

🎯 What It Does

Automate desktop interactions without APIs:

  • ✅ Click, type, drag, scroll
  • ✅ Capture screenshots
  • ✅ Recognize images (OpenCV template matching)
  • ✅ Extract text (Tesseract OCR)
  • ✅ Record and replay macros
  • ✅ Find windows by title
  • ✅ Clipboard operations
  • ✅ Safe mode with dry_run for testing

🔐 Safety Features (Built-In)

1. Safe Mode (Default: ON)

Blocks dangerous actions when enabled:

  • type, press_key, click, drag are monitored
  • Parameters are scanned for dangerous patterns: rm , del , C:\Windows\, /etc/, sudo, etc.
  • Blocked actions are logged

2. Dry-Run Mode

All actions support dry_run=true:

  • Action is logged but NOT executed
  • Use for testing before running real automation

3. Audit Logging

Every action logged to ~/.openclaw/skills/desktop-automation-logs/automation_YYYY-MM-DD.log

4. Thread Safety

All modules use locks to prevent race conditions.


📦 Installation

1. Extract Files

Place desktop-automation-ultra-local/ in:

  • Windows: C:\Users\<User>\.openclaw\workspace\skills\
  • Linux/macOS: ~/.openclaw/workspace/skills/

2. Install Dependencies

pip install -r requirements.txt

3. Optional: Tesseract for OCR

For find_text_on_screen functionality:

4. Restart OpenClaw

openclaw gateway restart

🚀 Quick Start

Basic Click

action: click
params:
  x: 100
  y: 100
  dry_run: true  # Test first!

Type Text

action: type
params:
  text: "Hello World"
  interval: 0.05  # Delay between keys
  dry_run: false

Find Image

action: find_image
params:
  template_path: "templates/button.png"
  confidence: 0.95

Extract Text (OCR)

action: read_text_ocr
params:
  lang: "fra"  # French

📖 Core Actions

Mouse & Keyboard

Action Parameters Returns
click x, y, button="left", dry_run {status, x, y}
type text, interval=0.05, dry_run {status, text}
press_key key, dry_run {status, key}
move_mouse x, y, duration=0.5, dry_run {status, x, y}
scroll amount=5, dry_run {status, amount}
drag start_x, start_y, end_x, end_y, duration=0.5, dry_run {status}
copy_to_clipboard text, dry_run {status}
paste_from_clipboard dry_run {status, length}

Screenshots & Windows

Action Parameters Returns
screenshot path="~/Desktop/screenshot.png", dry_run {status, path}
get_active_window dry_run {status, title, x, y, width, height}
list_windows dry_run {status, windows[], count}
activate_window title_substring, dry_run {status, title}

Image Recognition (requires OpenCV)

Action Parameters Returns
find_image template_path, confidence=0.9, dry_run {status, x, y, confidence}
find_image_multiscale template_path, confidence, scale_factors, dry_run {status, x, y, confidence, scale}
wait_for_image template_path, timeout=30.0, interval=0.5, confidence=0.9, dry_run {status, x, y, confidence}

OCR / Text Recognition (requires Tesseract)

Action Parameters Returns
find_text_on_screen text, lang="fra", dry_run {status, locations[], count}
find_all_text_on_screen text, lang="fra", dry_run {status, data[], count}
read_text_ocr lang="fra", dry_run {status, text, length}
read_text_region x, y, width, height, lang="fra", dry_run {status, text, length}
extract_screen_data region={}, output_format="json", lang="fra", dry_run {status, data[], count}

Macros

Action Parameters Returns
play_macro macro_path, speed=1.0, dry_run {status, executed, total, errors[]}
stop_macro — {status}
play_macro_with_subroutines macro_path, speed=1.0, sub_macros_dir, dry_run {status, executed, total, errors[]}

Safety Management

Action Parameters Returns
set_safe_mode enabled=true {status, safe_mode}
get_safety_status — {status, safe_mode_enabled, dangerous_patterns, dangerous_actions[]}

📝 Macro Format

Recorded macros are JSON with this structure:

{
  "events": [
    {
      "action": "click",
      "params": {"x": 100, "y": 50},
      "wait": 500
    },
    {
      "action": "type",
      "params": {"text": "Hello"},
      "wait": 200
    },
    {
      "action": "press_key",
      "params": {"key": "return"},
      "wait": 100
    }
  ]
}
  • action — action name
  • params — action parameters
  • wait — milliseconds to wait before next action

🔧 Advanced: Mouse Move Debouncing

To avoid recording hundreds of move_mouse events during a smooth drag, the recorder uses debouncing:

  • When you move the mouse, events are suppressed during movement
  • After you stop moving for N seconds (default: 1 sec), the final position is recorded
  • This reduces macro size dramatically while preserving intended end positions
  • Configurable via GUI: set debounce time (0.1–10 seconds)

Example:

  • Fast horizontal line → 1 move_mouse event (end coordinates)
  • Slow, stop-and-go → multiple move_mouse events (one per "stop")

🧪 Testing

Run the unit test suite:

python scripts/test_automation.py

Output:

test_dry_run_click ... ok
test_get_active_window ... ok
test_safe_mode_blocks_dangerous ... ok
...
Ran 13 tests
OK

📊 Logging

All actions logged to: ~/.openclaw/skills/desktop-automation-logs/automation_YYYY-MM-DD.log

Example:

[2026-03-15 10:23:45] [INFO] ActionManager: ActionManager initialized with safe_mode=True
[2026-03-15 10:23:46] [INFO] ActionManager: Clicked at (100, 50) with left button
[2026-03-15 10:23:47] [INFO] ActionManager: Typed: Hello World

⚙️ Configuration

Environment Variables

# Override log directory
export AUTOMATION_LOG_DIR=~/my_logs

# Disable safe mode globally (NOT recommended)
export AUTOMATION_SAFE_MODE=false

🐛 Troubleshooting

"pyautogui failsafe triggered"

Move mouse to corner of screen to stop.

OCR returns empty text

  • Ensure Tesseract is installed correctly
  • Check image quality (high contrast helps)
  • Try read_text_ocr instead of find_text_on_screen

Image recognition not finding template

  • Ensure template image exists and is correct format (PNG, JPG)
  • Try lower confidence threshold (e.g., 0.85 instead of 0.95)
  • Use find_image_multiscale to detect at different scales

Actions blocked by safe mode

This is intentional. To run dangerous actions:

action: set_safe_mode
params:
  enabled: false

Then execute your action. Re-enable safe mode immediately after:

action: set_safe_mode
params:
  enabled: true

📄 License

MIT License. See LICENSE file.


📚 Files Structure

desktop-automation-ultra-local/
├── SKILL.md                          (This file)
├── requirements.txt                  (Python dependencies)
├── lib/
│   ├── actions.py                   (Core click/type/drag actions)
│   ├── image_recognition.py         (OpenCV template matching)
│   ├── ocr_engine.py                (Tesseract OCR)
│   ├── macro_player.py              (Record/playback macros)
│   ├── safety_manager.py            (Safe mode, blocking)
│   └── utils.py                     (Logging, helpers)
├── scripts/
│   └── test_automation.py           (Unit tests)
└── recorded_macro/                  (Output: saved macros)

✅ Validation Checklist

  • All modules have proper error handling
  • Thread safety implemented (locks)
  • Safe mode enabled by default
  • Dry-run mode on all actions
  • Comprehensive logging
  • Unit tests (13 tests)
  • UTF-8 encoding for all text
  • No hardcoded paths (uses expanduser)
  • Graceful fallbacks for missing dependencies
  • Documentation complete

Status: PRODUCTION READY ✅


Last updated: 2026-03-15 Version: 2.0.0

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

automationdesktoppyautoguiocrmacrocross-platformopenclawrobotic-process-automationimage-recognition

同类 Skill