dsh-snip
hakuno410/dsh-snip
Press Alt+A on Windows to capture the screen, drag a rectangle over the frozen image shown inside the DSH window, and the crop lands in the composer as a draft attachment. The capture runs in a background PowerShell helper that opens no window of its own, and the paste goes through DSH's own file intake. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.
설치
dsh plugin --profile web add github:hakuno410/dsh-snipREADME
dsh-snip
WeChat-style region screenshot for DeepSeek Harness Desktop: press Alt+A, drag over the frozen screen, and the crop becomes a draft attachment in the composer.
What it does
- Alt+A anywhere (no need to focus the app first), or the scissors button in the composer tool row.
- The whole screen is captured instantly, and the app window comes forward showing that capture scaled to fit.
- Drag a rectangle; the size is shown live. Release to crop.
- The crop lands in the composer as a normal draft attachment — preview, remove, send with your text.
Escor right click cancels.
Why the selection is drawn in the page
The first version drew a full-screen topmost WinForms overlay from PowerShell. It worked, and it was a mistake: when that window's message loop stalled even once, the desktop was covered by a topmost black window that could not be dismissed — a "PowerShell is not responding" wedge that the user has to clean up in Task Manager.
So the work is split by strength:
| Part | Responsibility |
|---|---|
| PowerShell helper | Owns Alt+A, calls CopyFromScreen, writes a PNG. Never shows a visible window. |
| Browser | Shows the capture, drag-selects, crops on a canvas, feeds the composer |
If the helper dies, the worst case is "no capture" — never a blocked desktop.
Install
Plugins → Add plugin → /path/to/dsh-snip
Or from git:
git clone https://github.com/<you>/dsh-snip
# then Plugins → Add plugin → pick the cloned folder
Restart Desktop after installing so the page loads the Client half.
Requirements: Windows 10/11 and the Desktop app. PowerShell 5.1 (shipped with Windows) makes the Win32 capture call.
How the image reaches the composer
Not by touching the DOM of someone else's input. The Client builds a DataTransfer holding the PNG and dispatches a synthetic ClipboardEvent('paste') on document; DSH's own composer file intake accepts it and runs the normal path — validation, upload, thumbnail, removal. Same code path as a real Ctrl+V.
Endpoints
GET /api/snip/state → { ok, supported, ready, hotkey, hotkeyRegistered, seq, width, height }
POST /api/snip/capture → { ok, seq } starts a capture
GET /api/snip/events → SSE: state | captured | error | hotkey-failed
GET /api/snip/last.png → the last capture, image/png
Limits
- Windows only. Other platforms hide the button; the endpoints answer
supported: false. - The selector lives inside the app window, so you are picking on a scaled-down picture of the screen. A small window makes small targets hard — enlarge the window when you need pixel accuracy.
- If another app owns Alt+A, the button still works and the UI says so once.
- The capture is the screen at the moment the hotkey fired.
- The PNG stays on the machine; it only leaves if you send the message.
Layout
| Path | Role |
|---|---|
index.js | Host half: helper lifecycle, /api/snip/* routes, SSE fan-out |
client.js | Client half: scissors button, selector overlay, crop, paste injection |
snip.ps1 | Win32 side: global hotkey, virtual-screen grab, PNG write |
cordis.patch.yml | Bundle patch inserting the snip row |
locale/ | Plugin Manager title, description and detail document |
License
MIT
中文说明
按 Alt+A,DSH 窗口里弹出整屏截图的缩放视图,拖一个框,那张图就变成输入框里的附件。
用法
- 按 Alt+A(或点输入框左侧剪刀按钮),DSH 窗口会被带到最前。
- 整屏截图以"缩放到窗口里"的样子显示,外面压暗。
- 拖框,底部实时显示尺寸;松手即裁剪。
- 裁好的图进入输入框,成为草稿附件,可预览、删除、和你打的字一起发。
- 取消:
Esc或点右键。
原图落在 ~/.dsh/snip/last.png,每次覆盖。
为什么选择框在网页里
第一版是在 PowerShell 里用 WinForms 画全屏置顶覆盖层。它能用,但代价太大:那个窗口的消息循环卡住一次,整个桌面就被一块无法交互的顶层黑窗盖住,只能去任务管理器结束进程。
现在拆开:PowerShell 只负责抢热键 + 抓整屏存 PNG,不显示任何可见窗口;选择、裁剪、贴进输入框全部在浏览器里。助手挂了最多是截不出图,不会钉死桌面。
图进输入框的方式不是硬塞 DOM:构造 DataTransfer 派发合成 paste 事件,由 DSH 自己的文件摄取入口接住,走的就是官方流程。
限制
只在 Windows 桌面版可用;选择框在窗口内,看到的是缩放版截图,窗口小时不好瞄细小目标;Alt+A 被占用时按钮仍可用;截的是按下热键那一刻的屏幕。
许可
MIT