← 返回
未分类

windows-auto

Windows 桌面自动化技能,支持鼠标控制(移动/点击/拖拽/滚轮/截图)、键盘输入(文字输入/按键/组合键)、窗口管理(查找/聚焦/最大化/最小化/关闭/移动)、截图并发送文件。提供两种截图方式:Python pyautogui 截图(集成在自动化流程中)和 PowerShell + .NET 零依赖截图(支持区域截图和多显示器)。当用户需要自动化 Windows 桌面操作、控制鼠标键盘、管理窗口、执行 GUI 自动化任务、截图发送文件时使用。
Windows 桌面自动化技能,支持鼠标控制(移动/点击/拖拽/滚轮/截图)、键盘输入(文字输入/按键/组合键)、窗口管理(查找/聚焦/最大化/最小化/关闭/移动)、截图并发送文件。提供两种截图方式:Python pyautogui 截图(集成在自动化流程中)和 PowerShell + .NET 零依赖截图(支持区域截图和多显示器)。当用户需要自动化 Windows 桌面操作、控制鼠标键盘、管理窗口、执行 GUI 自动化任务、截图发送文件时使用。
user_73205fea
未分类 community v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 23
下载
💾 0
安装
1
版本
#latest

概述

Windows 桌面自动化

工具概览

脚本功能
--------------------------------------------------------------------------------------------
scripts/mouse.py鼠标:移动、点击、双击、拖拽、滚动、截图
scripts/keyboard.py键盘:文字输入、单键、组合热键
scripts/window.py窗口:列举、查找、聚焦、最大化/最小化、关闭、移动
scripts/screenshot_powershell.py🆕 PowerShell 截图:零依赖,支持全屏/区域/多显示器截图
scripts/screenshot_and_send.py截取全屏并准备发送到群聊
scripts/send_file.py发送任意文件(Word/PDF/图片等)到群聊

截图功能对比

方式命令依赖优点适用场景
-----------------------------------------------------------------------------------------------------------------------
Python 截图python mouse.py screenshotpyautogui + pillow与鼠标操作集成,流程统一自动化流程中,已安装依赖
PowerShell 截图python screenshot_powershell.py无(Windows 原生)零依赖,支持区域/多显示器轻量环境,不想装依赖
截图+发送python screenshot_and_send.pypyautogui + pillow截图后自动准备发送需要截图后推送到群聊

快速上手

安装依赖

# 完整安装(使用 Python 截图和鼠标控制功能时需要)
pip install pyautogui pillow pywin32

# 如果只使用 PowerShell 截图 + 键盘 + 窗口管理,则只需:
pip install pywin32

鼠标操作

python scripts/mouse.py pos                          # 查看当前坐标
python scripts/mouse.py move 500 300                 # 移动鼠标
python scripts/mouse.py click 500 300               # 左键点击
python scripts/mouse.py click 500 300 right         # 右键点击
python scripts/mouse.py dblclick 500 300            # 双击
python scripts/mouse.py drag 100 100 500 300        # 拖拽
python scripts/mouse.py scroll 500 300 3            # 向上滚动3格
python scripts/mouse.py screenshot output.png       # 截图(需要 pyautogui)

键盘操作

python scripts/keyboard.py type "你好世界"           # 输入文字(支持中文)
python scripts/keyboard.py press enter              # 按回车
python scripts/keyboard.py press tab                # 按Tab
python scripts/keyboard.py hotkey ctrl c            # Ctrl+C
python scripts/keyboard.py hotkey ctrl alt delete   # Ctrl+Alt+Del
python scripts/keyboard.py hotkey win r             # Win+R 打开运行

窗口管理

python scripts/window.py list                       # 列出所有窗口
python scripts/window.py find "记事本"              # 查找窗口
python scripts/window.py focus "记事本"             # 激活窗口
python scripts/window.py maximize "记事本"          # 最大化
python scripts/window.py minimize "记事本"          # 最小化
python scripts/window.py close "记事本"             # 关闭

PowerShell 截图(零依赖)🆕

# 全屏截图(主显示器)
python scripts/screenshot_powershell.py                              # 默认 screenshot.png
python scripts/screenshot_powershell.py desktop.png                  # 指定文件名

# 区域截图
python scripts/screenshot_powershell.py --region 0,0,800,600         # 截左上角 800×600
python scripts/screenshot_powershell.py shot.png --region 100,200,1024,768

# 多显示器全屏截图
python scripts/screenshot_powershell.py --all                        # 所有显示器拼接
python scripts/screenshot_powershell.py all_screens.png --all        # 指定文件名

底层原理:通过 PowerShell 调用 .NET 的 System.Windows.FormsSystem.Drawing 库直接截取桌面像素,无需安装任何 Python 第三方库。

截图并发送文件

# 1. 截图到 workspace
python scripts/screenshot_and_send.py              # 默认命名
python scripts/screenshot_and_send.py "会议记录"   # 自定义名称前缀

# 2. 发送任意文件到群聊
python scripts/send_file.py "文档.docx"            # 发送 Word
python scripts/send_file.py "报告.pdf"             # 发送 PDF
python scripts/send_file.py "截图.png"             # 发送图片

执行方式

直接通过 exec 工具在工作区运行脚本:

exec("python C:\\Users\\Administrator\\.openclaw\\workspace\\skills\\windows-automation\\scripts\\mouse.py click 500 300")

或切换到技能目录后运行:

exec("python scripts/mouse.py click 500 300", cwd="C:\\Users\\Administrator\\.openclaw\\workspace\\skills\\windows-automation")

参考资料

详见 references/reference.md,包含:坐标系统说明、紧急停止方法、常用热键速查、典型流程示例。

注意事项

  • ⚠️ 紧急中止:将鼠标快速移到屏幕左上角 (0,0) 可中止所有自动化操作
  • 中文输入通过剪贴板实现,需确保目标窗口已聚焦
  • 部分操作(如 UAC 弹窗)需要管理员权限

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-06-03 11:20 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

Nano Pdf

steipete
使用nano-pdf CLI通过自然语言指令编辑PDF
★ 276 📥 115,767
office-efficiency

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 379 📥 143,795
office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 925 📥 186,552