Files
MeshTerm/scripts/ladders/snap.ps1
T
Jean-Pierre MartineauandClaude Opus 5.5 a493a6a5eb Keep the calibration ladders in scripts/ladders, with the method
A ladder draws the candidates for a visual value side by side through
MeshTerm's own renderer and live constants, so JP can choose by eye.
The two that set constants are kept: hue_ladder.py (the node wheel's
lightness, 0.72 on 2026-10-29) and seam_ladder.py (SEAM_BLUR, rebuilt
from the 2026-09-16 tool), with contrast.py for the measurement that
comes first and ladderkit.py for what they share.

launch.ps1 opens a ladder in a new Windows Terminal window and waits
for the ladder's marker file; -Snap also takes a screenshot through
snap.ps1. It avoids the three traps that broke the launches this week:
wt quoting a forwarded command line as one file name, the tab
inheriting Claude Code's NO_COLOR=1, and Rich falling back to the
16-colour console API when virtual terminal processing is off. The
README explains the method and the traps.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 01:10:16 -04:00

33 lines
1.7 KiB
PowerShell

# SPDX-License-Identifier: Apache-2.0
#
# Take a screenshot of a Windows Terminal window, found by its title, and save it as a PNG.
# Claude examines this picture before it tells the user that a ladder is ready.
#
# scripts\ladders\snap.ps1 -Title "Ladder hue_ladder" -Out $env:TEMP\ladder.png
param([string]$Title, [string]$Out)
Add-Type -AssemblyName System.Drawing
Add-Type @'
using System;
using System.Runtime.InteropServices;
public static class LadderWindow {
[StructLayout(LayoutKind.Sequential)] public struct RECT { public int L, T, R, B; }
[DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string cls, string title);
[DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r);
[DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);
[DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
}
'@
[LadderWindow]::SetProcessDPIAware() | Out-Null # physical pixels, also on a scaled display
$window = [LadderWindow]::FindWindow('CASCADIA_HOSTING_WINDOW_CLASS', $Title)
if ($window -eq [IntPtr]::Zero) { Write-Error "no Windows Terminal window has the title '$Title'"; exit 1 }
[LadderWindow]::SetForegroundWindow($window) | Out-Null
Start-Sleep -Milliseconds 400
$rect = New-Object LadderWindow+RECT
[LadderWindow]::GetWindowRect($window, [ref]$rect) | Out-Null
$size = New-Object System.Drawing.Size ($rect.R - $rect.L), ($rect.B - $rect.T)
$bitmap = New-Object System.Drawing.Bitmap $size.Width, $size.Height
[System.Drawing.Graphics]::FromImage($bitmap).CopyFromScreen($rect.L, $rect.T, 0, 0, $size)
$bitmap.Save($Out, [System.Drawing.Imaging.ImageFormat]::Png)
"snapshot: $Out ($($size.Width)x$($size.Height))"