fix(computer): add PowerShell screenshot fallback for Windows Claude Code environments#2175
Draft
fix(computer): add PowerShell screenshot fallback for Windows Claude Code environments#2175
Conversation
…de Code Co-authored-by: quanru <11739753+quanru@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Bug] Fix error when triggering Midscene in Claude Code
fix(computer): add PowerShell screenshot fallback for Windows Claude Code environments
Mar 18, 2026
Deploying midscene with
|
| Latest commit: |
493cd48
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4993e06d.midscene.pages.dev |
| Branch Preview URL: | https://copilot-fix-midscene-trigger.midscene.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
npx @midscene/computer connectfails during health check on Windows when invoked from Claude Code (or similar MCP hosts), while the same command works fine in a standalone terminal. The screenshot step crashes with a garbled error—the Chinese "command not recognized" message in GBK encoding read as UTF-8:Root cause:
screenshot-desktopcompiles a .NET exe at runtime from a polyglot.bat/C# file and runs it from%TEMP%\screenCapture\. Claude Code's environment (UTF-8 code page 65001 and/or AppLocker/WDAC policies) prevents that dynamically-compiled, unsigned exe from being located or executed.Changes —
packages/computer/src/device.tsscreenshotViaWindowsPowerShell()method: takes a screenshot viapowershell.exeusingSystem.Windows.Forms.Screen+System.Drawing.Graphics.CopyFromScreen. The script is passed via-EncodedCommand(UTF-16LE base64), sidestepping shell-quoting and code-page issues entirely. PowerShell is a signed Microsoft binary not subject to the same execution restrictions.screenshotBase64(): on Windows, ifscreenshot-desktopthrows, the PowerShell path is tried automatically; both errors are surfaced if both fail.displayIdis sanitized ([a-zA-Z0-9\\.\-_:]only) before interpolation into the PowerShell string to prevent injection.process.pid + Date.now() + randomsuffix avoids collisions under concurrent calls.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.npmjs.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.