0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Claude CodeにWindowsのスクショを一瞬で見せる方法【VPS環境】

Last updated at Posted at 2025-07-12

この記事で実現できること

何ができるようになるの?

VPS上で動くClaude Codeに、Windows画面のスクショを3秒で見せられるようになります。

例えば、こんなやり取りが一瞬で:

> このエラーは何?  screenshot at /tmp/screenshot_20250713_062300.png

● これはTypeErrorです。
  13行目でundefinedのプロパティにアクセスしようとしています。

こんな人におすすめ

  • VPS上でClaude Code使ってる
  • Windowsローカルの画面を頻繁に見せたい
  • エラー画面、UI、グラフなどを解析してもらいたい
  • いちいちファイル転送するのが面倒

仕組み

  1. PowerShellでクリップボードを監視
  2. スクリーンショットが撮影されたら画像を検出
  3. 一時ファイルとして保存
  4. PuTTYのpscp.exeを使用してVPSに転送
  5. ファイルパスを含むコマンドをクリップボードにセット

使い方

ステップ1:バッチファイルをダブルクリック

自動的にスクリーンショットモードが起動します。

ステップ2:スクショ範囲を選択

見せたい部分を選択してください。

ステップ3:Claude Codeに貼り付け

# コマンドが自動でクリップボードに入ってるので
# SSHセッションでCtrl+V → Enter
> screenshot at /tmp/screenshot_20250713_062300.png

ステップ4:Claude Codeが画像を認識!

● 画像を確認しました。このエラーは...

実装

バッチファイルの作成

以下の内容で screenshot.bat を作成します:

@echo off
set VPS_USER=your-username
set VPS_HOST=your-vps-ip
set VPS_PASS=your-password

powershell -ExecutionPolicy Bypass -Command ^
"$ErrorActionPreference = 'SilentlyContinue'; ^
Add-Type -AssemblyName System.Windows.Forms; ^
Add-Type -AssemblyName System.Drawing; ^
[System.Windows.Forms.Clipboard]::Clear(); ^
[System.Windows.Forms.SendKeys]::SendWait('{PRTSC}'); ^
$timeout = 30; $elapsed = 0; ^
while ($elapsed -lt $timeout) { ^
    Start-Sleep -Milliseconds 500; ^
    $image = [System.Windows.Forms.Clipboard]::GetImage(); ^
    if ($image) { ^
        $timestamp = Get-Date -Format 'yyyyMMdd_HHmmss'; ^
        $filename = 'screenshot_' + $timestamp + '.png'; ^
        $remotePath = '/tmp/' + $filename; ^
        $tempFile = [System.IO.Path]::GetTempFileName() + '.png'; ^
        $image.Save($tempFile); ^
        $pscpPath = 'C:\\Program Files\\PuTTY\\pscp.exe'; ^
        if (Test-Path $pscpPath) { ^
            $process = Start-Process -FilePath $pscpPath -ArgumentList @('-pw', '%VPS_PASS%', $tempFile, ('%VPS_USER%@%VPS_HOST%:' + $remotePath)) -NoNewWindow -Wait -PassThru; ^
        } else { ^
            Invoke-WebRequest -Uri 'https://the.earth.li/~sgtatham/putty/latest/w64/pscp.exe' -OutFile 'pscp.exe'; ^
            $process = Start-Process -FilePath '.\\pscp.exe' -ArgumentList @('-pw', '%VPS_PASS%', $tempFile, ('%VPS_USER%@%VPS_HOST%:' + $remotePath)) -NoNewWindow -Wait -PassThru; ^
        } ^
        Remove-Item $tempFile; ^
        $command = 'screenshot at ' + $remotePath; ^
        [System.Windows.Forms.Clipboard]::SetText($command); ^
        Write-Host $command; ^
        break; ^
    } ^
    $elapsed += 0.5; ^
} ^
if ($elapsed -ge $timeout) { ^
    Write-Host 'Timeout' -ForegroundColor Red; ^
}"

設定(3箇所)

set VPS_USER=your-username  # あなたのユーザー名
set VPS_HOST=your-vps-ip    # VPSのIPアドレス  
set VPS_PASS=your-password  # SSHパスワード

セキュリティ

注意点

パスワードが平文で保存されるので:

  • 個人利用のみ
  • 他人がアクセスできない場所に保存
  • SSH鍵認証がより安全(下記参照)

SSH鍵認証の設定(より安全に!)

# 1. 鍵を生成
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519

# 2. 公開鍵をVPSに転送
type ~/.ssh/id_ed25519.pub | ssh username@vps-ip "cat >> ~/.ssh/authorized_keys"

# 3. バッチファイルから以下を削除
# - set VPS_PASS=your-password
# - -pw %VPS_PASS%

活用例

エラー解決

You: screenshot at /tmp/screenshot_20250713_062300.png
Claude: TypeErrorが発生していますね。13行目の...

UI/UXレビュー

You: このUIデザインどう思う?
You: screenshot at /tmp/screenshot_20250713_062300.png
Claude: ボタンの配色が良いですね!ただ、余白を...

データ分析

You: このグラフから何が読み取れる?
You: screenshot at /tmp/screenshot_20250713_062300.png
Claude: 売上が右肩上がりで推移していますが、3月に...

コード生成

You: この画面と同じUIを作って
You: screenshot at /tmp/screenshot_20250713_062300.png
Claude: Reactでコンポーネントを作成しますね...

まとめ

Claude Codeとの画像共有が超快適に!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?