dsh-desktop-uia: A Windows Desktop Control Plugin Based on UI Automation

Introduction

DeepSeek Harness (DSH) adopts a plugin-based architecture designed to manage tool ecosystems through configuration files. When developing agents that need to control desktop applications, traditional solutions often rely on screenshot recognition or coordinate guessing; this approach is not only fragile but also difficult to adapt to changes in window layouts. The dsh-desktop-uia plugin reads the window control tree via the Windows UI Automation (UIA) interface, utilizing stable Automation IDs to drive elements. It does not rely on screenshots; all write operations require approval, and all actions are auditable.

Installation and Activation

The plugin is published via npm, but you can also directly download the compiled package for installation. Ensure your environment meets the requirements before installing.

Installation Command

Use the official installation command to add the plugin:

dsh plugin --profile web add dsh-desktop-uia

Environment Requirements

  • Operating System: Supports Windows 10 or 11 (x64) only.
  • DSH Version: Requires a configuration-based installation. Compatibility has been verified for the 0.1.2‑rc.1 / 0.1.5‑rc.1 plugin contracts.
  • Dependency Toolchain: No additional installation of .NET SDK, NuGet, or MSVC is required. The plugin ships with a Sidecar, and the installation script uses the system’s built-in compiler for the build.

Manual Installation (Optional)

Download the zip package from Releases, extract it, and double-click install.cmd to complete the installation. The script will place the plugin into the node_modules of your DSH configuration file.

Core Functions

The plugin provides a set of desktop_* tools for managing windows, reading control trees, executing actions, and waiting for state changes. Depending on the nature of the function, some operations are free, while others require approval.

Window Management

  • desktop_windows: Lists top-level windows (including handle, PID, title, state, etc.) and manages them. The list and focus actions are free; other actions (minimize, maximize, move, close, etc.) require approval.
  • desktop_launch: Launches programs, documents, or URIs (e.g., notepad or ms-settings:).
  • desktop_wait: Waits for windows to appear, elements to appear, values to change, or elements to disappear, avoiding inefficient sleep loops.

Exploration and Inspection

  • desktop_snapshot: Reads the window control tree. It can find elements by name, type, or Automation ID via the query parameter. The default is auto mode (with budget probing), but all or none (fastest) can also be selected.
  • desktop_inspect: Inspects detailed information of a single element, including bounds, class name, enabled/focused state, supported Patterns, and current value.

Actions and Input

  • desktop_act: Performs operations such as click, right-click, double-click, hover, focus, invoke, set value, select, and drag. All such operations require approval.
  • desktop_input: Inputs Unicode text (supports CJK characters) or sends key combinations (e.g., ctrl+s).
  • desktop_clipboard: Reads or replaces clipboard text. Write operations require approval.

Utility Capabilities

  • desktop_screenshot: Captures a window or the entire desktop as a PNG image.
  • desktop_clipboard: Reads or replaces clipboard text.

Typical Usage

The following commands demonstrate how to launch a program, find elements, and perform actions:

# Launch Notepad
desktop_launch notepad

# Input text into the current window
desktop_input "Hello World"

# Find the element named "Save" (snapshot)
desktop_snapshot query {name: "Save"}

# Click the element with ID el_12
desktop_act click el_12

# Wait for the window named "Calculator" to appear
desktop_wait window "Calculator"

Notes

  • Permissions and Approval: Since the plugin runs with the permissions of the DSH process, operations involving UI modification (such as desktop_act, desktop_input) and clipboard writing require approval. Only list and focus for desktop_windows are free.
  • Performance Limits: For slow-responding windows (e.g., Chromium, Java applications), the plugin automatically limits the number of nodes read (maxNodes 300) and depth (maxDepth 5) to prevent blocking.
  • Element Stability: Element IDs are generated based on UIA Runtime IDs. If a window is rebuilt, the ID becomes invalid and reports STALE_ELEMENT; a new snapshot is required.
  • Action Feedback: The system detects and reports feedback such as “New window appeared,” “Slow provider,” and “Duplicate no-op click” (after two consecutive identical operations, a third identical operation will be rejected with a prompt to check the element state).

Summary

dsh-desktop-uia provides stable, UIA-based desktop control capabilities for DSH, replacing fragile coordinate guessing with ID-driven interactions and ensuring operation safety through an approval mechanism. It is suitable for scenarios requiring automation agents in a Windows environment. For more details and source code, please refer to the Plugin Directory or the GitHub Repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye