Skip to content

Latest commit

 

History

History
200 lines (144 loc) · 7.46 KB

File metadata and controls

200 lines (144 loc) · 7.46 KB

ScreenCode

Windows tray application that bridges clipboard images and Claude Code in WSL. Press Ctrl+V in Windows Terminal with a screenshot in the clipboard — ScreenCode saves the image to the WSL filesystem and pastes the file path, so Claude Code can read it directly.

How it works

  1. Copy a screenshot to the clipboard (Win+Shift+S, Print Screen, etc.)
  2. Focus Windows Terminal (with Claude Code or any WSL shell)
  3. Press Ctrl+V or Shift+Insert
  4. ScreenCode intercepts the paste, saves the image as PNG to ~/.img/, and types the Linux file path into the terminal
  5. Claude Code reads the image from the path

If the clipboard contains text (not an image), paste works normally — no interception.

Tray icon states

Icon Meaning
Clipboard empty
T Text in clipboard
Im Image in clipboard (will be intercepted)
○ gray Interception disabled

Installation

Prerequisites

  • Windows 10/11
  • .NET 10 SDK
  • WSL with any Linux distribution

Build

dotnet publish src/ScreenCode/ScreenCode.csproj -c Release -r win-x64

The output is in src/ScreenCode/bin/Release/net10.0-windows/win-x64/publish/.

Run

src\ScreenCode\bin\Release\net10.0-windows\win-x64\publish\ScreenCode.exe

A green circle appears in the system tray. Right-click for options.

Auto-start with Windows

Right-click the tray icon → check Start with Windows. This adds a registry entry to HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.

Settings

Settings are stored in %LOCALAPPDATA%\ScreenCode\settings.json. Edit via tray menu → Settings... or directly:

{
  "wslDistro": "",
  "imageDirectory": "",
  "linuxUser": "",
  "enableLog": false,
  "restoreClipboard": true
}
Setting Default Description
wslDistro auto-detected WSL distribution name (e.g. Ubuntu, ubuntu-dev)
imageDirectory ~/.img Linux path where screenshots are saved
linuxUser Windows username Linux username for home directory
enableLog false Write debug log to %LOCALAPPDATA%\ScreenCode\screencode.log
restoreClipboard true Restore original image to clipboard after pasting the path

Empty values trigger auto-detection. WSL distro is detected via wsl --list --quiet.

Architecture

Ctrl+V  →  KeyboardHook (WH_KEYBOARD_LL)
               │
               ├── Not Windows Terminal? → pass through
               ├── No image in clipboard? → pass through
               │
               └── Image detected → suppress keystroke
                       │
                    Worker thread (STA)
                       │
                       ├── ClipboardHelper.GetImage()
                       ├── ImageSaver.Save() → \\wsl.localhost\<distro>\...
                       └── PathInjector.InjectPath()
                               │
                               ├── SetText(path) → clipboard
                               └── SendInput(Ctrl+V) → paste path

All Win32 interop is via P/Invoke — no third-party dependencies.

Component Purpose
KeyboardHook Global low-level keyboard hook (WH_KEYBOARD_LL)
WindowDetector Checks if foreground window is Windows Terminal
ClipboardHelper Clipboard access with retry logic
ImageSaver Saves PNG to WSL filesystem via UNC path
PathInjector Injects file path via clipboard + simulated Ctrl+V
ClipboardMonitor Listens for clipboard changes (WM_CLIPBOARDUPDATE)
IconGenerator Programmatic tray icon generation via GDI+
Settings JSON config with auto-detection fallbacks
StartupManager Registry-based auto-start management

Tech stack

  • .NET 10.0 / C# 14
  • Windows Forms (NotifyIcon only — no windows)
  • Win32 P/Invoke (SetWindowsHookEx, SendInput, GetForegroundWindow)
  • System.Drawing.Common (GDI+ for icon generation and image saving)

License

MIT


ScreenCode (Русский)

Приложение в системном трее Windows, которое связывает буфер обмена с Claude Code в WSL. Нажмите Ctrl+V в Windows Terminal со скриншотом в буфере — ScreenCode сохранит изображение в файловую систему WSL и вставит путь к файлу, чтобы Claude Code мог его прочитать.

Как это работает

  1. Скопируйте скриншот в буфер обмена (Win+Shift+S, Print Screen и т.д.)
  2. Переключитесь на Windows Terminal (с Claude Code или любым WSL-шеллом)
  3. Нажмите Ctrl+V или Shift+Insert
  4. ScreenCode перехватывает вставку, сохраняет изображение как PNG в ~/.img/ и вводит Linux-путь к файлу в терминал
  5. Claude Code читает изображение по этому пути

Если в буфере текст (не изображение) — вставка работает как обычно, без перехвата.

Иконки в трее

Иконка Значение
Буфер пуст
T Текст в буфере
Im Изображение в буфере (будет перехвачено)
○ серая Перехват отключён

Установка

Требования

  • Windows 10/11
  • .NET 10 SDK
  • WSL с любым дистрибутивом Linux

Сборка

dotnet publish src/ScreenCode/ScreenCode.csproj -c Release -r win-x64

Результат в src/ScreenCode/bin/Release/net10.0-windows/win-x64/publish/.

Запуск

src\ScreenCode\bin\Release\net10.0-windows\win-x64\publish\ScreenCode.exe

В системном трее появится зелёный кружок. Правый клик — меню.

Автозапуск с Windows

Правый клик по иконке → отметьте Start with Windows. Добавляет запись в реестр HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.

Настройки

Хранятся в %LOCALAPPDATA%\ScreenCode\settings.json. Открыть через меню трея → Settings... или вручную:

{
  "wslDistro": "",
  "imageDirectory": "",
  "linuxUser": "",
  "enableLog": false,
  "restoreClipboard": true
}
Параметр По умолчанию Описание
wslDistro автоопределение Имя WSL-дистрибутива (напр. Ubuntu, ubuntu-dev)
imageDirectory ~/.img Linux-путь для сохранения скриншотов
linuxUser имя пользователя Windows Имя пользователя Linux для домашней директории
enableLog false Писать лог в %LOCALAPPDATA%\ScreenCode\screencode.log
restoreClipboard true Восстанавливать картинку в буфере обмена после вставки пути

Пустые значения — автоопределение. Дистрибутив WSL определяется через wsl --list --quiet.

Лицензия

MIT