Initial commit with translated description

This commit is contained in:
2026-03-29 14:37:38 +08:00
commit 94cd04ef62
4 changed files with 135 additions and 0 deletions

56
SKILL.md Normal file
View File

@@ -0,0 +1,56 @@
---
name: windows-ui-automation
description: "使用PowerShell自动化Windows GUI交互。"
---
# Windows UI Automation
Control the Windows desktop environment programmatically.
## Core Capabilities
- **Mouse**: Move, click (left/right/double), drag.
- **Keyboard**: Send text, press special keys (Enter, Tab, Alt, etc.).
- **Windows**: Find, focus, minimize/maximize, and screenshot windows.
## Usage Guide
### Mouse Control
Use the provided PowerShell script `mouse_control.ps1.txt`:
```powershell
# Move to X, Y
powershell -File skills/windows-ui-automation/mouse_control.ps1.txt -Action move -X 500 -Y 500
# Click at current position
powershell -File skills/windows-ui-automation/mouse_control.ps1.txt -Action click
# Right click
powershell -File skills/windows-ui-automation/mouse_control.ps1.txt -Action rightclick
```
### Keyboard Control
Use `keyboard_control.ps1.txt`:
```powershell
# Type text
powershell -File skills/windows-ui-automation/keyboard_control.ps1.txt -Text "Hello World"
# Press Enter
powershell -File skills/windows-ui-automation/keyboard_control.ps1.txt -Key "{ENTER}"
```
### Window Management
To focus a window by title:
```powershell
$wshell = New-Object -ComObject WScript.Shell; $wshell.AppActivate("Notepad")
```
## Best Practices
1. **Safety**: Always move the mouse slowly or include delays between actions.
2. **Verification**: Take a screenshot before and after complex UI actions to verify state.
3. **Coordinates**: Remember that coordinates (0,0) are at the top-left of the primary monitor.

6
_meta.json Normal file
View File

@@ -0,0 +1,6 @@
{
"ownerId": "kn76wjjc3n518fh6het03rr7wx80yfjy",
"slug": "windows-ui-automation",
"version": "1.0.0",
"publishedAt": 1770809270308
}

13
keyboard_control.ps1.txt Normal file
View File

@@ -0,0 +1,13 @@
param (
[string]$Text,
[string]$Key
)
Add-Type -AssemblyName System.Windows.Forms
if ($Text) {
[System.Windows.Forms.SendKeys]::SendWait($Text)
}
if ($Key) {
[System.Windows.Forms.SendKeys]::SendWait($Key)
}

60
mouse_control.ps1.txt Normal file
View File

@@ -0,0 +1,60 @@
param (
[Parameter(Mandatory=$true)]
[ValidateSet("move", "click", "rightclick", "doubleclick")]
[string]$Action,
[int]$X = 0,
[int]$Y = 0
)
Add-Type -AssemblyName System.Windows.Forms
switch ($Action) {
"move" {
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($X, $Y)
}
"click" {
$source = @"
using System;
using System.Runtime.InteropServices;
public class Mouse {
[DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
}
"@
Add-Type -TypeDefinition $source -ErrorAction SilentlyContinue
[Mouse]::mouse_event(0x02, 0, 0, 0, 0) # Left Down
Start-Sleep -Milliseconds 50
[Mouse]::mouse_event(0x04, 0, 0, 0, 0) # Left Up
}
"rightclick" {
$source = @"
using System;
using System.Runtime.InteropServices;
public class MouseRight {
[DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
}
"@
Add-Type -TypeDefinition $source -ErrorAction SilentlyContinue
[MouseRight]::mouse_event(0x08, 0, 0, 0, 0) # Right Down
Start-Sleep -Milliseconds 50
[MouseRight]::mouse_event(0x10, 0, 0, 0, 0) # Right Up
}
"doubleclick" {
$source = @"
using System;
using System.Runtime.InteropServices;
public class MouseDouble {
[DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
}
"@
Add-Type -TypeDefinition $source -ErrorAction SilentlyContinue
[MouseDouble]::mouse_event(0x02, 0, 0, 0, 0)
[MouseDouble]::mouse_event(0x04, 0, 0, 0, 0)
Start-Sleep -Milliseconds 50
[MouseDouble]::mouse_event(0x02, 0, 0, 0, 0)
[MouseDouble]::mouse_event(0x04, 0, 0, 0, 0)
}
}