Windows 桌面自动化技能,支持鼠标控制(移动/点击/拖拽/滚轮/截图)、键盘输入(文字输入/按键/组合键)、窗口管理(查找/聚焦/最大化/最小化/关闭/移动)、截图并发送文件。提供两种截图方式:Python pyautogui 截图(集成在自动化流程中)和 PowerShell + .NET 零依赖截图(支持区域截图和多显示器)。当用户需要自动化 Windows 桌面操作、控制鼠标键盘、管理窗口、执行 GUI 自动化任务、截图发送文件时使用。
Windows 桌面自动化
功能概述
Windows 桌面自动化是一项面向实际任务的技能,主要用于scripts/mouse.py;鼠标:移动、点击、双击、拖拽、滚动、截图;
核心要点
- scripts/keyboard.py;
- 键盘:文字输入、单键、组合热键;
- scripts/window.py;
使用与执行
窗口:列举、查找、聚焦、最大化/最小化、关闭、移动;scripts/screenshot_powershell.py;🆕 PowerShell 截图 :零依赖,支持全屏/区域/。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。
结果检查与注意事项
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
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 screenshot |
pyautogui + pillow | 与鼠标操作集成,流程统一 | 自动化流程中,已安装依赖 |
| PowerShell 截图 | python screenshot_powershell.py |
无(Windows 原生) | 零依赖,支持区域/多显示器 | 轻量环境,不想装依赖 |
| 截图+发送 | python screenshot_and_send.py |
pyautogui + 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.Forms 和 System.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 弹窗)需要管理员权限
热门AI工具
相关专题
开启被禁用的 Windows 更新:方法一:服务管理器中将其设置为自动启动并启动服务;方法二:Windows 设置中取消暂停更新;方法三:使用命令提示符启动 wuauserv 和 cryptSvc 服务并重启计算机。想了解更多相关内容,请阅读专题下面的文章。
3642
2025.03.27
此windows副本不是正版的解决办法:1、执行重新激活;2、使用命令提示符;3、调整服务设置;4、使用激活工具;5、更新系统。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。
1479
2024.08.23
windows打印机无法打印可能是由连接、驱动程序、打印机设置、文档、墨水耗尽、纸张或硬件故障引起的。想了解更多windows的相关内容,可以阅读本专题下面的文章。
3374
2024.04.15
Windows驱动精灵是一个免费的驱动程序管理工具,可帮助您轻松查找、下载和安装丢失或过时的驱动程序。想了解更多驱动精灵的相关内容,可以阅读本专题下面的文章。
2978
2024.04.15
linux和windows的主要区别有:1. 内核:linux使用开源内核,而windows使用专有内核;2. 许可证和成本:linux大多免费开源,而windows需要购买许可证等等。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。
6389
2024.04.12
热门下载
相关下载
精品课程
最新文章


