| name | Desktop Control |
| description | Control mouse, keyboard, and screen for desktop automation tasks |
Desktop Control Skill
This skill provides comprehensive desktop automation capabilities through PyAutoGUI, allowing AI agents to control the mouse, keyboard, take screenshots, and interact with the desktop environment.
How to Use This Skill
As an AI agent, you can invoke desktop automation commands using the uvx desktop-agent CLI.
Command Structure
All commands follow this pattern:
uvx desktop-agent <category> <command> [arguments] [options]
Categories:
mouse - Mouse control
keyboard - Keyboard input
screen - Screenshots and screen analysis
message - User dialogs
app - Application control (open, focus, list windows)
Available Commands
🖱️ Mouse Control (mouse)
Control cursor movement and clicks.
uvx desktop-agent mouse move <x> <y> [--duration SECONDS]
uvx desktop-agent mouse click [x] [y] [--button left|right|middle] [--clicks N]
uvx desktop-agent mouse double-click [x] [y]
uvx desktop-agent mouse right-click [x] [y]
uvx desktop-agent mouse middle-click [x] [y]
uvx desktop-agent mouse drag <x> <y> [--duration SECONDS] [--button BUTTON]
uvx desktop-agent mouse scroll <clicks> [x] [y]
uvx desktop-agent mouse position
Examples:
uvx desktop-agent mouse move 960 540 --duration 0.5
uvx desktop-agent mouse right-click 500 300
uvx desktop-agent mouse scroll -5
⌨️ Keyboard Control (keyboard)
Type text and execute keyboard shortcuts.
uvx desktop-agent keyboard write "<text>" [--interval SECONDS]
uvx desktop-agent keyboard press <key> [--presses N] [--interval SECONDS]
uvx desktop-agent keyboard hotkey "<key1>,<key2>,..."
uvx desktop-agent keyboard keydown <key>
uvx desktop-agent keyboard keyup <key>
Examples:
uvx desktop-agent keyboard write "Hello World" --interval 0.05
uvx desktop-agent keyboard hotkey "ctrl,c"
uvx desktop-agent keyboard hotkey "ctrl,shift,esc"
uvx desktop-agent keyboard press enter --presses 3
Common Key Names:
- Modifiers:
ctrl, shift, alt, win
- Special:
enter, tab, esc, space, backspace, delete
- Function:
f1 through f12
- Arrows:
up, down, left, right
🖼️ Screen & Screenshots (screen)
Capture screenshots and analyze screen content. Supports targeting specific windows.
uvx desktop-agent screen screenshot <filename> [--region "x,y,width,height"] [--window <title>] [--active]
uvx desktop-agent screen locate <image_path> [--confidence 0.0-1.0] [--window <title>] [--active]
uvx desktop-agent screen locate-center <image_path> [--confidence 0.0-1.0] [--window <title>] [--active]
uvx desktop-agent screen locate-text-coordinates <text> [--window <title>] [--active]
uvx desktop-agent screen read-all-text [--window <title>] [--active]
uvx desktop-agent screen pixel <x> <y>
uvx desktop-agent screen size
uvx desktop-agent screen on-screen <x> <y>
Examples:
uvx desktop-agent screen screenshot active.png --active
uvx desktop-agent screen screenshot chrome.png --window "Google Chrome"
uvx desktop-agent screen locate-center button.png --window "Notepad"
💬 Message Dialogs (message)
Display user interaction dialogs.
uvx desktop-agent message alert "<text>" [--title TITLE] [--button BUTTON]
uvx desktop-agent message confirm "<text>" [--title TITLE] [--buttons "OK,Cancel"]
uvx desktop-agent message prompt "<text>" [--title TITLE] [--default TEXT]
uvx desktop-agent message password "<text>" [--title TITLE] [--mask CHAR]
Examples:
uvx desktop-agent message alert "Task completed!"
uvx desktop-agent message confirm "Continue with operation?"
uvx desktop-agent message prompt "Enter your name:"
📱 Application Control (app)
Control applications across Windows, macOS, and Linux.
uvx desktop-agent app open <name> [--arg ARGS...]
uvx desktop-agent app focus <name>
uvx desktop-agent app list
Examples:
uvx desktop-agent app open notepad
uvx desktop-agent app open "chrome" --arg "https://google.com"
uvx desktop-agent app open "Safari"
uvx desktop-agent app focus "Untitled - Notepad"
uvx desktop-agent app list
Common Automation Workflows
Workflow 1: Open Application and Type
uvx desktop-agent app open notepad
uvx desktop-agent app focus notepad
uvx desktop-agent keyboard write "Hello from Desktop Skill!"
Workflow 2: Screenshot + Analysis
uvx desktop-agent screen size
uvx desktop-agent screen screenshot current_screen.png
uvx desktop-agent screen locate save_button.png
Workflow 3: Form Filling
uvx desktop-agent mouse click 300 200
uvx desktop-agent keyboard write "John Doe"
uvx desktop-agent keyboard press tab
uvx desktop-agent keyboard write "john@example.com"
uvx desktop-agent keyboard press enter
Workflow 4: Copy/Paste Operations
uvx desktop-agent keyboard hotkey "ctrl,a"
uvx desktop-agent keyboard hotkey "ctrl,c"
uvx desktop-agent mouse click 500 600
uvx desktop-agent keyboard hotkey "ctrl,v"
Safety Considerations
When using this skill, AI agents should:
- Verify coordinates: Use
screen size and on-screen before clicking
- Add delays: Insert appropriate delays between commands for UI responsiveness
- Validate images: Ensure image files exist before using
locate commands
- Handle failures: Commands may fail if windows change or elements move
- User safety: Always confirm destructive actions with user via
message confirm
Troubleshooting
PyAutoGUI Fail-Safe
PyAutoGUI has a fail-safe: moving mouse to screen corner aborts operations. This is a safety feature.
Image not found
When using screen locate, ensure:
- Image file exists and path is correct
- Adjust
--confidence (try 0.7-0.9)
- Image matches exact screen appearance (resolution, colors)
Getting Help
uvx desktop-agent --help
uvx desktop-agent mouse --help
uvx desktop-agent keyboard --help
uvx desktop-agent screen --help
uvx desktop-agent message --help
uvx desktop-agent mouse move --help
Integration Tips for AI Agents
- Always check screen size first when working with absolute coordinates
- Use relative positioning when possible (e.g., get current position, calculate offset)
- Combine commands for complex workflows
- Validate before executing (e.g., check if image exists on screen)
- Provide user feedback using message dialogs for important operations
- Handle errors gracefully - commands may fail if UI state changes
Performance Notes
- Mouse movements with
--duration are animated and take time
- Image location (
locate) can be slow on large screens - use regions when possible
- Keyboard commands are generally fast (< 100ms)
- Screenshots depend on screen resolution and region size
Output Format
All commands output structured JSON by default, ideal for programmatic use by AI agents:
uvx desktop-agent mouse position
Response Schema
All JSON responses follow this schema:
{
"success": true,
"command": "category.command",
"timestamp": "2026-01-31T10:00:00Z",
"duration_ms": 150,
"data": { ... },
"error": null
}
Error Response Schema
{
"success": false,
"command": "category.command",
"timestamp": "2026-01-31T10:00:00Z",
"duration_ms": 50,
"data": null,
"error": {
"code": "image_not_found",
"message": "Image file 'button.png' not found",
"details": {},
"recoverable": true
}
}
Error Codes
| Code | Description |
|---|
success | Command succeeded |
invalid_argument | Invalid command arguments |
coordinates_out_of_bounds | Coordinates outside screen |
image_not_found | Image file not found or not on screen |
window_not_found | Target window not found |
ocr_failed | OCR operation failed |
application_not_found | Application not found |
permission_denied | Permission denied |
platform_not_supported | Platform not supported |
timeout | Operation timed out |
unknown_error | Unknown error |
Mouse move:
uvx desktop-agent mouse move 960 540
{"success": true, "command": "mouse.move", "timestamp": "...", "duration_ms": 150, "data": {"x": 960, "y": 540, "duration": 0}, "error": null}
Screen size:
uvx desktop-agent screen size
{"success": true, "command": "screen.size", "timestamp": "...", "duration_ms": 5, "data": {"size": {"width": 1920, "height": 1080}}, "error": null}
Locate image:
uvx desktop-agent screen locate button.png
{"success": true, "command": "screen.locate", "timestamp": "...", "duration_ms": 250, "data": {"image_found": true, "bounding_box": {"left": 100, "top": 200, "width": 50, "height": 30, "center_x": 125, "center_y": 215}}, "error": null}
List windows:
uvx desktop-agent app list
{"success": true, "command": "app.list", "timestamp": "...", "duration_ms": 100, "data": {"windows": ["Untitled - Notepad", "Google Chrome", "Visual Studio Code"]}, "error": null}
Error example:
uvx desktop-agent screen locate missing.png
{"success": false, "command": "screen.locate", "timestamp": "...", "duration_ms": 50, "data": null, "error": {"code": "image_not_found", "message": "Image file 'missing.png' not found", "details": {}, "recoverable": true}}
Effective Usage Guide for AI Agents
This section teaches AI agents how to use this skill effectively with optimal command sequences and best practices.
🎯 Core Strategy: Observe First, Then Act
Always understand the current state before performing actions. This avoids clicking wrong coordinates or typing in the wrong window.
Recommended Initial Sequence:
uvx desktop-agent screen size
uvx desktop-agent app list
uvx desktop-agent mouse position
📋 Recommended Command Sequences by Task
Open and Interact with Application
uvx desktop-agent app open notepad
uvx desktop-agent app list
uvx desktop-agent app focus "Notepad"
uvx desktop-agent keyboard write "Hello World"
uvx desktop-agent app open notepad
uvx desktop-agent keyboard write "Hello World"
Find and Click UI Element (Image-Based)
uvx desktop-agent screen locate-center button.png --confidence 0.8
uvx desktop-agent mouse click 125 215
uvx desktop-agent mouse click 125 215
Find and Click UI Element (Text-Based with OCR)
uvx desktop-agent screen read-all-text --active
uvx desktop-agent screen locate-text-coordinates "Save" --active
uvx desktop-agent screen locate-text-coordinates "OK" --window "Dialog Title"
Fill a Form with Multiple Fields
uvx desktop-agent mouse click 300 200
uvx desktop-agent keyboard write "John Doe"
uvx desktop-agent mouse click 300 250
uvx desktop-agent keyboard write "john@example.com"
uvx desktop-agent mouse click 300 300
uvx desktop-agent keyboard write "555-1234"
uvx desktop-agent mouse click 300 200
uvx desktop-agent keyboard write "John Doe"
uvx desktop-agent keyboard press tab
uvx desktop-agent keyboard write "john@example.com"
uvx desktop-agent keyboard press tab
uvx desktop-agent keyboard write "555-1234"
uvx desktop-agent keyboard press enter
Take Targeted Screenshots for Analysis
uvx desktop-agent app list --json
uvx desktop-agent screen screenshot app.png --window "Google Chrome"
uvx desktop-agent screen screenshot active.png --active
uvx desktop-agent screen size
uvx desktop-agent screen screenshot full.png
Safe Drag and Drop
uvx desktop-agent mouse move 100 200
uvx desktop-agent mouse position
uvx desktop-agent mouse drag 500 400 --duration 0.5
uvx desktop-agent mouse drag 500 400 --duration 1.0
🔄 Error Recovery Patterns
When Window Not Found
uvx desktop-agent app focus "Chrome"
uvx desktop-agent app list
uvx desktop-agent app focus "Google Chrome"
When Image Not Found
uvx desktop-agent screen locate button.png --confidence 0.9
uvx desktop-agent screen locate button.png --confidence 0.7
uvx desktop-agent screen screenshot current.png --active
When Click Seems to Miss
uvx desktop-agent screen size
uvx desktop-agent screen on-screen 1500 900
uvx desktop-agent mouse move 1500 900
uvx desktop-agent mouse click
⚡ Performance Optimization
Minimize Screenshots
uvx desktop-agent screen screenshot button_area.png --region "100,200,200,100"
uvx desktop-agent screen screenshot chrome.png --window "Google Chrome"
uvx desktop-agent screen screenshot full.png
Batch Keyboard Input
uvx desktop-agent keyboard write "This is a complete sentence with all the text."
uvx desktop-agent keyboard write "This is "
uvx desktop-agent keyboard write "a complete "
uvx desktop-agent keyboard write "sentence."
Use Hotkeys Over Mouse When Possible
uvx desktop-agent keyboard hotkey "ctrl,s"
uvx desktop-agent keyboard hotkey "ctrl,a"
uvx desktop-agent keyboard hotkey "ctrl,shift,s"
uvx desktop-agent mouse click 50 30
uvx desktop-agent mouse click 60 80
🛡️ Defensive Programming Patterns
Always Verify Critical Actions
uvx desktop-agent message confirm "This will delete all files. Continue?" --title "Warning"
Use JSON Mode for Reliable Parsing
uvx desktop-agent screen locate button.png
uvx desktop-agent screen locate button.png
Validate Before Multi-Step Operations
uvx desktop-agent app list
uvx desktop-agent screen locate-text-coordinates "File" --active
uvx desktop-agent mouse click <returned_x> <returned_y>
uvx desktop-agent screen locate-text-coordinates "Save As" --active
uvx desktop-agent mouse click <returned_x> <returned_y>
🎮 Platform-Specific Considerations
Windows
uvx desktop-agent keyboard hotkey "win,d"
uvx desktop-agent keyboard hotkey "win,e"
uvx desktop-agent keyboard hotkey "alt,tab"
uvx desktop-agent keyboard hotkey "win,r"
uvx desktop-agent app open notepad
uvx desktop-agent app open calc
uvx desktop-agent app open mspaint
macOS
uvx desktop-agent keyboard hotkey "command,space"
uvx desktop-agent keyboard hotkey "command,tab"
uvx desktop-agent keyboard hotkey "command,q"
uvx desktop-agent keyboard hotkey "command,shift,3"
uvx desktop-agent app open "Safari"
uvx desktop-agent app open "TextEdit"
Linux
uvx desktop-agent app open firefox
uvx desktop-agent app open gedit
uvx desktop-agent keyboard hotkey "alt,f2"
📊 Decision Tree: Choosing the Right Command
Want to interact with an app?
├── App not running → `app open <name>`
├── App running but not focused → `app focus <name>`
└── Need to verify windows → `app list`
Want to find a UI element?
├── Have reference image → `screen locate-center <image>`
├── Know the text label → `screen locate-text-coordinates "<text>"`
└── Need to see all text → `screen read-all-text --active`
Want to click something?
├── Know exact coordinates → `mouse click <x> <y>`
├── Need to find first → Use locate commands above, then click returned coords
└── Not sure if on screen → `screen on-screen <x> <y>` first
Want to type something?
├── Regular text → `keyboard write "<text>"`
├── Keyboard shortcut → `keyboard hotkey "<key1>,<key2>"`
├── Single key press → `keyboard press <key>`
└── Multiple of same key → `keyboard press <key> --presses N`
Integration Tips for AI Agents
- Always check screen size first when working with absolute coordinates
- Use relative positioning when possible (e.g., get current position, calculate offset)
- Combine commands for complex workflows
- Validate before executing (e.g., check if image exists on screen)
- Provide user feedback using message dialogs for important operations
- Handle errors gracefully - commands may fail if UI state changes