dsh-gui-guard: A Reliability Layer for Windows Window Operations

Introduction

The common approach for an agent to operate the Windows desktop in DSH (DeepSeek Harness) is: obtain coordinates via screenshot or OCR, then invoke click and type actions. The log often says “clicked”, yet the interface shows no response at all. The problem may not lie in the model or control recognition, but rather in the window being minimized, not being in the foreground, DPI scaling causing a mix-up between physical and logical pixels, and the fact that “activate window” and “send keystrokes” are squeezed into the same call, causing the first character to be swallowed. These are unrelated to specific applications—they are inherent pitfalls in how the Windows API is used.

If the agent or developer has to handle restoration, foregrounding, coordinate conversion, and stepwise input every time, the cost is high and steps are easily missed. dsh-gui-guard (repository 7gzgn/dsh-gui-guard) consolidates the above steps into a single atomic call, serving as a reliability layer for Windows window operations used by DSH: zero dependencies, fully local, no network access. The following describes what it does, how to use it, and how it works alongside similar capabilities.

What Is This

Maintained by 7gzgn and categorized as a workflow plugin in the SkillHub community directory. In one sentence: before clicking by coordinates or typing into a window, it first confirms whether the window can currently be operated reliably, and handles activation ordering and coordinate space during clicks and input.

The plugin depends on user32.dll at the bottom layer and only supports Windows; the system must be able to spawn powershell.exe (it will prefer pwsh if available). Node.js >=18 is required. The license is MIT; the package version is v0.1.1 (consistent with the directory page).

The declared DSH compatibility range is >=0.2.0-rc.2 <0.3.0-0, covering the entire 0.2 line. At runtime, if defineTool from @deepseek-ai/dsh-tools cannot be obtained, it degrades gracefully; if ctx.systemPrompt does not exist, the announcement section is skipped, avoiding dragging down the entire host.

Core Functions

The README groups the capabilities into five action categories, invoked through the unified tool gui_guard:

Action Purpose
list List all processes with windows (to help find the target) and mark which are minimized
probe Health check: whether minimized, whether in the foreground, DPI scaling, screen logical/physical resolution, and notes
prepare Restore the window and bring it to the foreground, optionally also moving its position or changing its size
click Safe click: restore and activate first, then land the point; coordinates are accepted in physical pixels by default and converted internally to logical pixels
type Safe input: split “activation” and “sending” into two steps to avoid swallowing the first character

Several key design points (all from the repository documentation):

  • The coordinate space must be explicit: the default is space: "physical" (aligned with screenshots/OCR); if the coordinates come from GetWindowRect, pass space: "logical".
  • Responses report “what was done”: for example, click echoes back the requested coordinates, the actual landing point, whether the cursor matches, whether the window was in the foreground before clicking, etc., making troubleshooting easier.
  • No OCR or element location provided; for self-drawn interfaces such as Flutter / Electron / Qt, if UIA cannot capture the controls, this plugin can only guarantee that the click lands at the given coordinates, not that the control responds.
  • The backend is a pure-ASCII PowerShell script; Node and PowerShell communicate only via base64 JSON, avoiding command-line JSON quoting and escaping issues.
  • Each call spawns a PowerShell process, taking a few hundred milliseconds per call; it focuses on “clicking accurately” rather than “clicking fast”.

Relationship with dsh-computer-use-win: the latter provides raw capabilities such as UIA, screenshots, OCR, window management, keyboard and mouse; this plugin handles reliability. The recommended workflow is to first use dsh-computer-use-win to obtain coordinates, then use gui_guard to land the point.

Installation and Activation

The SkillHub directory page (7gzgn/dsh-gui-guard) indicates that the plugin is installable and currently at v0.1.1. In the DSH ecosystem, plugins are typically integrated from community directories or repositories; the README and package.json on which this article is based do not provide a fixed dsh plugin add … one-line command. Before installation, please check the directory page or the GitHub README for instructions consistent with your current DSH version.

Once enabled, the agent can invoke the above actions through the Cordis-registered gui_guard tool. The plugin runs with the permissions of the current DSH process; before installation, please review the source code and the MIT license yourself to confirm it meets your security policy.

Typical Usage

First perform a health check on the target window to confirm minimized, foreground, and DPI status. The window title example is “Notepad” (replace with the actual title on your machine):

gui_guard({ action: "probe", window: "记事本" })

The JSON example structure returned by probe is as follows (see the README for field meanings):

{
  "ok": true,
  "minimized": false,
  "foreground": true,
  "rect": { "left": -7, "top": -7, "width": 1721, "height": 1033 },
  "dpi": { "window": 144, "scale": 1.5 },
  "screen": { "logicalWidth": 1707, "physicalWidth": 2560 },
  "notes": ["DPI scaling is active (150%): screenshot/OCR tools report PHYSICAL pixels …"]
}

After confirming the window is operable, perform a safe click using physical pixel coordinates (consistent with the screenshot/OCR coordinate space):

gui_guard({ action: "click", window: "记事本", x: 1412, y: 1 })

Note the requested and applied fields in the response: you submit physical pixels, and the actual landing point is logical pixels; the conversion is performed by the tool, and both sets of values are returned. If the window was not in the foreground previously, the first click may only serve to activate it; the README suggests that if the control does not respond, click once more at the same coordinates:

{
  "ok": true,
  "requested": { "x": 1412, "y": 1, "space": "physical" },
  "applied":   { "x": 941,  "y": 0, "space": "logical", "scale": 1.5 },
  "cursorMatches": true,
  "wasForeground": false,
  "note": "Window was not foreground: this click first activated it. If the target control did not react, click once more at the same coordinates."
}

To list processes with windows or to pre-prepare a window, set action to list, prepare, or type, and pass the corresponding window and other parameters as described in the README.

Applicable Scenarios and Notes

Who it is for: Developers or workflow authors running DSH on Windows who already use or plan to use dsh-computer-use-win and similar tools to obtain coordinates, but want to hand off common pitfalls such as minimized/foreground/DPI/input timing to a dedicated layer.

Not intended to replace: Cross-platform desktop automation, pure UIA control tree operations, or scenarios requiring high-frequency clicking (a process overhead of several hundred milliseconds per call).

Permissions and security: The tool can restore and activate windows and send clicks and keystrokes, with behavior consistent with the user session running DSH. The community directory SkillHub is an independent site with no official affiliation with DeepSeek / High-Flyer; the plugin’s source is based on the GitHub repository 7gzgn/dsh-gui-guard.

Conclusion

dsh-gui-guard does not solve “where do the coordinates come from”, but rather “how to click accurately and type stably once the coordinates are available”. If your workflow sees the agent repeatedly reporting “clicked but no response”, you can first run probe, then click/type, and troubleshoot against the returned physical/logical coordinates and foreground state.

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

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

Xiaoye