Desktop Control (Windows)技能使用说明
2026-03-27
新闻来源:网淘吧
围观:22
电脑广告
手机广告
桌面控制——完整的Windows应用程序控制
仅发布说明(ClawHub)
此发布包包含脚本,文件扩展名为.ps1.txt因为发布功能仅接受文本文件。 下载后,请将每个*.ps1.txt文件重命名为*.ps1并放入scripts/文件夹以使用此技能。
控制此Windows计算机上的任何桌面应用程序。启动程序、管理窗口、模拟输入、控制VSCode以及监控进程——全部通过PowerShell脚本实现。
重要提示:脚本位置
所有脚本均相对于此技能文件夹定位:
SKILL_DIR = ~/.openclaw/workspace/skills/desktop-control/scripts
运行脚本时,请始终使用完整路径:
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/<script>.ps1" -Action <action> [params]
重要:安全规则
- 在关闭窗口前——若窗口可能包含未保存的工作,请向用户确认
- 在终止进程前— 除非用户明确要求终止,否则始终与用户确认
- 发送输入前— 首先确保正确的窗口已获得焦点
- 剪贴板— 如果即将覆盖剪贴板内容,请警告用户
操作参考
1. 窗口管理 (app-control.ps1)
管理应用程序窗口 — 启动、关闭、聚焦、调整大小、移动、贴靠。
列出所有可见窗口
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action list-windows
返回:PID、窗口标题、位置(X,Y)、大小(W×H)、状态(正常/最小化/最大化)
启动应用程序
# By name (searches PATH and common locations) powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action launch -Target "notepad" # By full path powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action launch -Target "C:\Program Files\MyApp\app.exe" # With arguments powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action launch -Target "code" -Arguments "C:\Users\ibach\project"
聚焦(置于前台)
# By window title (partial match) powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action focus -Target "Visual Studio Code" # By PID powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action focus -ProcId 12345
优雅地关闭窗口
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action close -Target "Notepad"
最小化 / 最大化 / 恢复
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action minimize -Target "Visual Studio Code" powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action maximize -Target "Visual Studio Code" powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action restore -Target "Visual Studio Code"
移动窗口
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action move -Target "Notepad" -X 100 -Y 200
调整窗口大小
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action resize -Target "Notepad" -Width 800 -Height 600
贴靠窗口(半屏)
# Options: left, right, top, bottom, topleft, topright, bottomleft, bottomright powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/app-control.ps1" -Action snap -Target "Notepad" -Position left
2. 输入模拟 (input-sim.ps1)
向任何应用程序模拟键盘和鼠标输入。
重要提示:在发送输入之前,请务必先使用app-control.ps1 -Action focus
来聚焦目标窗口。
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action type-text -Text "Hello, World!"
输入文本
# Common shortcuts: Ctrl+S, Ctrl+C, Ctrl+V, Ctrl+Z, Alt+F4, Ctrl+Shift+P, Win+D powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action send-keys -Keys "Ctrl+S" powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action send-keys -Keys "Ctrl+Shift+P" powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action send-keys -Keys "Alt+Tab"
发送键盘快捷键
# Keys: Enter, Tab, Escape, Backspace, Delete, Up, Down, Left, Right, Home, End, PageUp, PageDown, F1-F12 powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action send-keys -Keys "Enter" powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action send-keys -Keys "F5"
发送特殊按键
# Left click powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action mouse-click -X 500 -Y 300 # Right click powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action mouse-click -X 500 -Y 300 -Button right # Double click powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action mouse-click -X 500 -Y 300 -DoubleClick
在坐标处点击鼠标
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action mouse-move -X 500 -Y 300
移动鼠标
# Scroll up (positive) or down (negative) powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action mouse-scroll -Clicks 3 powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/input-sim.ps1" -Action mouse-scroll -Clicks -3
滚动3. VSCode 控制 (vscode-control.ps1
)通过code
CLI 和扩展来控制 Visual Studio Code。
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action open-file -Path "C:\Users\ibach\project\main.py"
打开一个文件
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action goto -Path "C:\Users\ibach\project\main.py" -Line 42
在特定行打开一个文件
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action open-folder -Path "C:\Users\ibach\project"
打开一个文件夹/工作区
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action open-diff -Path "file1.py" -Path2 "file2.py"
打开差异视图
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action list-extensions
列出已安装的扩展
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action install-extension -ExtensionId "ms-python.python"
卸载扩展
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action uninstall-extension -ExtensionId "ms-python.python"
在VSCode中打开新终端
# This focuses VSCode and sends Ctrl+` to toggle terminal powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action new-terminal
打开VSCode命令面板
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action command-palette
按名称运行VSCode命令
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/vscode-control.ps1" -Action run-command -Command "workbench.action.toggleSidebarVisibility"
4. 进程管理 (process-manager.ps1)
监控和管理运行中的进程。
列出运行中的进程
# All processes powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action list # Filter by name powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action list -Name "code" # Top N by memory powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action list -SortBy memory -Top 10
获取详细进程信息
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action info -ProcId 12345
启动新进程
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action start -Path "notepad.exe" -Arguments "C:\file.txt"
终止进程(需先向用户确认)
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action kill -ProcId 12345 powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action kill -Name "notepad"
监控进程资源使用情况
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/process-manager.ps1" -Action monitor -ProcId 12345 -Duration 10
5. 屏幕与系统信息 (screen-info.ps1)
获取显示信息、窗口详情、剪贴板内容和屏幕截图。
列出显示器/监视器
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action displays
获取活动(焦点)窗口信息
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action active-window
获取详细窗口信息
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action window-info -Target "Visual Studio Code"
截取屏幕截图
# Full screen powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action screenshot -OutputPath "$HOME/screenshot.png" # Specific window powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action screenshot -Target "Notepad" -OutputPath "$HOME/notepad-screenshot.png"
读取剪贴板
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action clipboard-get
设置剪贴板文本
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action clipboard-set -Text "Text to copy"
获取系统信息(运行时间、操作系统、分辨率)
powershell -ExecutionPolicy Bypass -File "$HOME/.openclaw/workspace/skills/desktop-control/scripts/screen-info.ps1" -Action system-info
常见工作流程
在VSCode中打开文件并跳转到指定行
1. vscode-control.ps1 -Action goto -Path "C:\path\to\file.py" -Line 42
在特定应用程序中输入内容
1. app-control.ps1 -Action focus -Target "Notepad" 2. input-sim.ps1 -Action type-text -Text "Hello World"
在任何应用程序中保存当前文档
1. app-control.ps1 -Action focus -Target "<app name>" 2. input-sim.ps1 -Action send-keys -Keys "Ctrl+S"
并排排列两个窗口
1. app-control.ps1 -Action snap -Target "Visual Studio Code" -Position left 2. app-control.ps1 -Action snap -Target "Chrome" -Position right
终止冻结的应用程序
1. process-manager.ps1 -Action list -Name "frozen-app" (note the PID) 2. ASK USER FOR CONFIRMATION 3. process-manager.ps1 -Action kill -ProcId <pid>
截取特定窗口的屏幕截图
1. screen-info.ps1 -Action screenshot -Target "Chrome" -OutputPath "$HOME/chrome.png"
错误处理
- 如果脚本返回退出代码0 → 成功
- 如果脚本返回退出代码1 → 错误(查看标准错误输出以获取详细信息)
- 如果未找到窗口 → 尝试列出窗口先获取确切的标题
- 如果codeCLI未找到 → VSCode可能不在PATH中;请尝试先启动它
故障排除
- "未找到窗口"→ 使用列出窗口查看确切的窗口标题,以便更精确地匹配
- “访问被拒绝”→ 某些系统进程需要管理员权限;请通知用户
- 输入无效→ 确保目标窗口已获得焦点并且在前台
- 未找到VSCode命令行工具→ 请尝试code --version命令;如果缺失,请从开始菜单启动VSCode
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~