|
By: Paul S Cilwa |
Posted: 3/29/2026 |
|
Page Views: 145 |
| Hashtags: #LookHere #Screenshot #Windows #Claude #MCP #NET #Grayscale #JPEG #Win32 #PrintWindow |
| A lightweight .NET command-line tool that captures any Windows application window as a compact grayscale JPEG screenshot for Claude. |
| Estimated reading time: 3 minute(s) (671 words) |
The Problem
When Claude needs to see a window on my desktop, the screenshot has to travel through the MCP
(Model Context Protocol) as a base64-encoded string inside a JSON response. Full-color,
full-resolution PNGs can easily run to several megabytes--far too large to fit comfortably in an
MCP tool result. And even if you could squeeze them through, Claude doesn't need all that color
information just to read a dialog box or check a layout.
LookHere solves this by producing screenshots that are tiny but perfectly readable: grayscale,
tone-quantized, and aggressively JPEG-compressed. A typical capture of a desktop window comes in
around 50-60KB--small enough to base64-encode and pass through MCP without breaking a sweat.
Download the Setup file here.
How It Works
Under the hood, LookHere does four things:
- Finds the window. It enumerates all visible windows using the Win32
EnumWindows API and matches against the title substring you provide. No need to
specify an exact title--just enough to be unique.
- Captures it. It uses
the Win32
PrintWindow API with the PW_RENDERFULLCONTENT flag, which
captures the window's contents even if it's partially obscured by other windows. If
PrintWindow fails (some apps don't cooperate), it falls back to a screen-coordinate
copy.
- Converts to grayscale. A
ColorMatrix transformation
converts the capture to grayscale using the standard luminance weights (0.299R + 0.587G + 0.114B).
This alone cuts the information content dramatically.
- Quantizes tones.
Instead of 256 shades of gray, LookHere reduces the palette to a configurable number of tones (128
by default). Fewer distinct gray values means the JPEG compressor has an easier job, producing much
smaller files without noticeably affecting readability.
The result gets encoded as a JPEG at a configurable quality level (default 30, which is very
aggressive but still perfectly legible for UI elements and text).
Usage
From the command line:
LookHere app="Window Title" [quality=30] [tones=128] [out=path.jpg]
Parameters
| Parameter | Required | Default | Description |
app | Yes | -- | A substring of the target window's title.
Case-insensitive. Must match exactly one visible window. |
quality | No | 30 | JPEG quality, 1-100. Lower values produce
smaller files. 30 is surprisingly readable for UI screenshots. |
tones | No | 128 | Number of grayscale levels, 2-256. Fewer
tones = smaller files. 128 provides a good balance. |
out |
No | %TEMP%\LookHere.jpg | Output file path. Defaults to the system temp
directory. |
Output
LookHere writes the captured image to the output path and prints two lines to stdout:
- The full path to the output file
- A summary line like:
1008x793, 128 tones,
quality 30, 54KB
Exit codes: 0 for success, 1 for missing arguments, 2 for window not found, 3 for zero-size window
(typically minimized).
Built With
LookHere is a single-file .NET 10.0 console application targeting net10.0-windows. It
uses Windows Forms (for System.Drawing) but has no external NuGet dependencies. The
entire program is under 170 lines of C#.
Win32 APIs used:
EnumWindows / GetWindowText -- window enumeration
PrintWindow -- off-screen window captureGetWindowRect --
window dimensions
Why Grayscale?
You might wonder why I didn't just compress harder or resize the image. Resizing throws away
spatial detail--text becomes unreadable. Heavy JPEG compression on color images creates ugly chroma
artifacts. But grayscale sidesteps both problems: there's no color information to smear, and the
compressor only has one channel to worry about. The result is a file that's a fraction of the size
of a color JPEG at the same resolution, with text that's still sharp and legible.
The tone quantization is the other secret weapon. By snapping 256 possible gray values down to 128
(or fewer), you create large regions of identical pixels that JPEG's DCT compression handles
beautifully. It's like giving the compressor a head start.