[{"data":1,"prerenderedAt":1837},["ShallowReactive",2],{"content-/auto-focus-on-notification":3,"all-pages-for-dir":1835,"og-image-/auto-focus-on-notification":1836},{"id":4,"title":5,"body":6,"category":1817,"description":1818,"extension":1819,"meta":1820,"navigation":130,"ogImage":1821,"path":1822,"project_name":1823,"published":1824,"publishedAt":1825,"seo":1826,"stem":1827,"tags":1828,"todo":1821,"unpublished":1824,"updatedAt":1821,"__hash__":1834},"pages/2026-03/2026-03-25/auto-focus-on-notification.md","Windows Terminal 自動フォーカス実装ガイド",{"type":7,"value":8,"toc":1794},"minimark",[9,13,17,26,30,43,46,60,63,66,76,78,81,85,88,98,729,733,739,744,873,889,893,896,901,904,961,965,968,975,1116,1121,1156,1158,1161,1165,1203,1207,1227,1229,1232,1236,1242,1247,1266,1388,1391,1396,1400,1415,1711,1715,1720,1724,1743,1745,1748,1754,1756,1760,1790],[10,11,5],"h1",{"id":12},"windows-terminal-自動フォーカス実装ガイド",[14,15,16],"h2",{"id":16},"概要",[18,19,20,21,25],"p",{},"Claude Code の ",[22,23,24],"code",{},"notification"," フックが発火したとき、Windows Terminal を自動的に最前面に持ってきて、該当ペインにフォーカスを当てる仕組みを実装する。",[27,28,29],"h3",{"id":29},"ゴール",[31,32,33,37,40],"ul",{},[34,35,36],"li",{},"別アプリ（Chrome等）を操作中でも、通知が来たらWindows Terminalが自動で最前面に来る",[34,38,39],{},"4分割ペインのうち、通知を出したペインに自動フォーカスが当たる",[34,41,42],{},"あとはEnterを押すだけで操作を続行できる",[27,44,45],{"id":45},"前提環境",[31,47,48,51,54,57],{},[34,49,50],{},"Windows Terminal（4分割ペイン: 左上・右上・左下・右下）",[34,52,53],{},"Claude Code セッションを各ペインで非同期実行",[34,55,56],{},"既存の音声通知フックが動作済み",[34,58,59],{},"PowerShell 7.5+",[61,62],"hr",{},[14,64,65],{"id":65},"アーキテクチャ",[67,68,73],"pre",{"className":69,"code":71,"language":72},[70],"language-text","Claude Code (notification hook)\n  ├── 既存: 音声通知スクリプト (そのまま)\n  └── 新規: auto-focus.ps1\n        ├── 環境変数 $env:PANE_POS で自分の位置を判定\n        ├── Win32 API (SetForegroundWindow) でターミナルを最前面化\n        └── SendKeys (Alt+矢印) で該当ペインにフォーカス移動\n","text",[22,74,71],{"__ignoreMap":75},"",[61,77],{},[14,79,80],{"id":80},"実装手順",[27,82,84],{"id":83},"step-1-自動フォーカススクリプトの作成","Step 1: 自動フォーカススクリプトの作成",[18,86,87],{},"以下のファイルを作成する。",[18,89,90,94,95],{},[91,92,93],"strong",{},"ファイルパス:"," ",[22,96,97],{},"~/.claude/scripts/auto-focus.ps1",[67,99,103],{"className":100,"code":101,"language":102,"meta":75,"style":75},"language-powershell shiki shiki-themes vitesse-light vitesse-light","# auto-focus.ps1\n# Claude Code notification フックから呼び出される\n# Windows Terminal を最前面にし、該当ペインにフォーカスを当てる\n\n# --- Win32 API 定義 ---\nAdd-Type @\"\nusing System;\nusing System.Runtime.InteropServices;\npublic class Win32Focus {\n    [DllImport(\"user32.dll\")]\n    public static extern bool SetForegroundWindow(IntPtr hWnd);\n\n    [DllImport(\"user32.dll\")]\n    public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);\n\n    [DllImport(\"user32.dll\")]\n    public static extern IntPtr GetForegroundWindow();\n\n    [DllImport(\"user32.dll\")]\n    public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);\n\n    [DllImport(\"user32.dll\")]\n    public static extern bool IsIconic(IntPtr hWnd);\n}\n\"@\n\n# --- 定数 ---\n$SW_RESTORE = 9\n$KEYEVENTF_KEYUP = 0x0002\n$VK_MENU = 0x12  # Alt キー\n\n# --- Windows Terminal のウィンドウハンドルを取得 ---\n$wtProcess = Get-Process -Name \"WindowsTerminal\" -ErrorAction SilentlyContinue |\n    Select-Object -First 1\n\nif (-not $wtProcess) {\n    Write-Error \"Windows Terminal が見つかりません\"\n    exit 1\n}\n\n$hwnd = $wtProcess.MainWindowHandle\n\nif ($hwnd -eq [IntPtr]::Zero) {\n    Write-Error \"Windows Terminal のウィンドウハンドルを取得できません\"\n    exit 1\n}\n\n# --- 最小化されていたら復元 ---\nif ([Win32Focus]::IsIconic($hwnd)) {\n    [Win32Focus]::ShowWindow($hwnd, $SW_RESTORE)\n}\n\n# --- フォアグラウンドロック回避 ---\n# バックグラウンドプロセスから SetForegroundWindow を呼ぶには\n# Alt キーをシミュレートしてロックを解除する必要がある\n[Win32Focus]::keybd_event($VK_MENU, 0, 0, [UIntPtr]::Zero)          # Alt down\n[Win32Focus]::keybd_event($VK_MENU, 0, $KEYEVENTF_KEYUP, [UIntPtr]::Zero)  # Alt up\n\n# --- Windows Terminal を最前面に ---\n[Win32Focus]::SetForegroundWindow($hwnd)\n\n# 少し待ってフォーカスが安定するのを待つ\nStart-Sleep -Milliseconds 200\n\n# --- ペインフォーカス移動 ---\n# 環境変数 PANE_POS に基づいて対象ペインにフォーカスを移す\n# 戦略: まず確実に左上に移動（←↑連打）してから目的のペインへ移動\n$panePos = $env:PANE_POS\nif (-not $panePos) {\n    # PANE_POS 未設定の場合はウィンドウ最前面化のみで終了\n    Write-Host \"PANE_POS が未設定のため、ウィンドウ最前面化のみ実行しました\"\n    exit 0\n}\n\n# WScript.Shell の SendKeys を使って Alt+矢印 を送信\n$wsh = New-Object -ComObject WScript.Shell\n\n# まず左上にリセット（最大2回ずつ送れば確実に左上に到達する）\nStart-Sleep -Milliseconds 100\n$wsh.SendKeys(\"%{LEFT}\")   # Alt+Left\nStart-Sleep -Milliseconds 50\n$wsh.SendKeys(\"%{LEFT}\")   # Alt+Left\nStart-Sleep -Milliseconds 50\n$wsh.SendKeys(\"%{UP}\")     # Alt+Up\nStart-Sleep -Milliseconds 50\n$wsh.SendKeys(\"%{UP}\")     # Alt+Up\nStart-Sleep -Milliseconds 50\n\n# 目的のペインに移動\nswitch ($panePos) {\n    \"top-left\" {\n        # 既に左上にいるので何もしない\n    }\n    \"top-right\" {\n        $wsh.SendKeys(\"%{RIGHT}\")  # Alt+Right\n    }\n    \"bottom-left\" {\n        $wsh.SendKeys(\"%{DOWN}\")   # Alt+Down\n    }\n    \"bottom-right\" {\n        $wsh.SendKeys(\"%{RIGHT}\")  # Alt+Right\n        Start-Sleep -Milliseconds 50\n        $wsh.SendKeys(\"%{DOWN}\")   # Alt+Down\n    }\n    default {\n        Write-Warning \"不明な PANE_POS: $panePos (top-left / top-right / bottom-left / bottom-right を指定してください)\"\n    }\n}\n\nWrite-Host \"フォーカス移動完了: $panePos\"\n","powershell",[22,104,105,113,119,125,132,138,144,150,156,162,168,174,179,184,190,195,200,206,211,216,222,227,232,238,244,250,255,261,267,273,279,284,290,296,302,307,313,319,325,330,335,341,346,352,358,363,368,373,379,385,391,396,401,407,413,419,425,431,436,442,448,453,459,465,470,476,482,488,494,500,506,512,518,523,528,534,540,545,551,557,563,569,574,579,585,590,595,600,605,611,617,623,629,635,641,647,652,658,664,669,675,680,686,691,696,702,708,713,718,723],{"__ignoreMap":75},[106,107,110],"span",{"class":108,"line":109},"line",1,[106,111,112],{},"# auto-focus.ps1\n",[106,114,116],{"class":108,"line":115},2,[106,117,118],{},"# Claude Code notification フックから呼び出される\n",[106,120,122],{"class":108,"line":121},3,[106,123,124],{},"# Windows Terminal を最前面にし、該当ペインにフォーカスを当てる\n",[106,126,128],{"class":108,"line":127},4,[106,129,131],{"emptyLinePlaceholder":130},true,"\n",[106,133,135],{"class":108,"line":134},5,[106,136,137],{},"# --- Win32 API 定義 ---\n",[106,139,141],{"class":108,"line":140},6,[106,142,143],{},"Add-Type @\"\n",[106,145,147],{"class":108,"line":146},7,[106,148,149],{},"using System;\n",[106,151,153],{"class":108,"line":152},8,[106,154,155],{},"using System.Runtime.InteropServices;\n",[106,157,159],{"class":108,"line":158},9,[106,160,161],{},"public class Win32Focus {\n",[106,163,165],{"class":108,"line":164},10,[106,166,167],{},"    [DllImport(\"user32.dll\")]\n",[106,169,171],{"class":108,"line":170},11,[106,172,173],{},"    public static extern bool SetForegroundWindow(IntPtr hWnd);\n",[106,175,177],{"class":108,"line":176},12,[106,178,131],{"emptyLinePlaceholder":130},[106,180,182],{"class":108,"line":181},13,[106,183,167],{},[106,185,187],{"class":108,"line":186},14,[106,188,189],{},"    public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);\n",[106,191,193],{"class":108,"line":192},15,[106,194,131],{"emptyLinePlaceholder":130},[106,196,198],{"class":108,"line":197},16,[106,199,167],{},[106,201,203],{"class":108,"line":202},17,[106,204,205],{},"    public static extern IntPtr GetForegroundWindow();\n",[106,207,209],{"class":108,"line":208},18,[106,210,131],{"emptyLinePlaceholder":130},[106,212,214],{"class":108,"line":213},19,[106,215,167],{},[106,217,219],{"class":108,"line":218},20,[106,220,221],{},"    public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);\n",[106,223,225],{"class":108,"line":224},21,[106,226,131],{"emptyLinePlaceholder":130},[106,228,230],{"class":108,"line":229},22,[106,231,167],{},[106,233,235],{"class":108,"line":234},23,[106,236,237],{},"    public static extern bool IsIconic(IntPtr hWnd);\n",[106,239,241],{"class":108,"line":240},24,[106,242,243],{},"}\n",[106,245,247],{"class":108,"line":246},25,[106,248,249],{},"\"@\n",[106,251,253],{"class":108,"line":252},26,[106,254,131],{"emptyLinePlaceholder":130},[106,256,258],{"class":108,"line":257},27,[106,259,260],{},"# --- 定数 ---\n",[106,262,264],{"class":108,"line":263},28,[106,265,266],{},"$SW_RESTORE = 9\n",[106,268,270],{"class":108,"line":269},29,[106,271,272],{},"$KEYEVENTF_KEYUP = 0x0002\n",[106,274,276],{"class":108,"line":275},30,[106,277,278],{},"$VK_MENU = 0x12  # Alt キー\n",[106,280,282],{"class":108,"line":281},31,[106,283,131],{"emptyLinePlaceholder":130},[106,285,287],{"class":108,"line":286},32,[106,288,289],{},"# --- Windows Terminal のウィンドウハンドルを取得 ---\n",[106,291,293],{"class":108,"line":292},33,[106,294,295],{},"$wtProcess = Get-Process -Name \"WindowsTerminal\" -ErrorAction SilentlyContinue |\n",[106,297,299],{"class":108,"line":298},34,[106,300,301],{},"    Select-Object -First 1\n",[106,303,305],{"class":108,"line":304},35,[106,306,131],{"emptyLinePlaceholder":130},[106,308,310],{"class":108,"line":309},36,[106,311,312],{},"if (-not $wtProcess) {\n",[106,314,316],{"class":108,"line":315},37,[106,317,318],{},"    Write-Error \"Windows Terminal が見つかりません\"\n",[106,320,322],{"class":108,"line":321},38,[106,323,324],{},"    exit 1\n",[106,326,328],{"class":108,"line":327},39,[106,329,243],{},[106,331,333],{"class":108,"line":332},40,[106,334,131],{"emptyLinePlaceholder":130},[106,336,338],{"class":108,"line":337},41,[106,339,340],{},"$hwnd = $wtProcess.MainWindowHandle\n",[106,342,344],{"class":108,"line":343},42,[106,345,131],{"emptyLinePlaceholder":130},[106,347,349],{"class":108,"line":348},43,[106,350,351],{},"if ($hwnd -eq [IntPtr]::Zero) {\n",[106,353,355],{"class":108,"line":354},44,[106,356,357],{},"    Write-Error \"Windows Terminal のウィンドウハンドルを取得できません\"\n",[106,359,361],{"class":108,"line":360},45,[106,362,324],{},[106,364,366],{"class":108,"line":365},46,[106,367,243],{},[106,369,371],{"class":108,"line":370},47,[106,372,131],{"emptyLinePlaceholder":130},[106,374,376],{"class":108,"line":375},48,[106,377,378],{},"# --- 最小化されていたら復元 ---\n",[106,380,382],{"class":108,"line":381},49,[106,383,384],{},"if ([Win32Focus]::IsIconic($hwnd)) {\n",[106,386,388],{"class":108,"line":387},50,[106,389,390],{},"    [Win32Focus]::ShowWindow($hwnd, $SW_RESTORE)\n",[106,392,394],{"class":108,"line":393},51,[106,395,243],{},[106,397,399],{"class":108,"line":398},52,[106,400,131],{"emptyLinePlaceholder":130},[106,402,404],{"class":108,"line":403},53,[106,405,406],{},"# --- フォアグラウンドロック回避 ---\n",[106,408,410],{"class":108,"line":409},54,[106,411,412],{},"# バックグラウンドプロセスから SetForegroundWindow を呼ぶには\n",[106,414,416],{"class":108,"line":415},55,[106,417,418],{},"# Alt キーをシミュレートしてロックを解除する必要がある\n",[106,420,422],{"class":108,"line":421},56,[106,423,424],{},"[Win32Focus]::keybd_event($VK_MENU, 0, 0, [UIntPtr]::Zero)          # Alt down\n",[106,426,428],{"class":108,"line":427},57,[106,429,430],{},"[Win32Focus]::keybd_event($VK_MENU, 0, $KEYEVENTF_KEYUP, [UIntPtr]::Zero)  # Alt up\n",[106,432,434],{"class":108,"line":433},58,[106,435,131],{"emptyLinePlaceholder":130},[106,437,439],{"class":108,"line":438},59,[106,440,441],{},"# --- Windows Terminal を最前面に ---\n",[106,443,445],{"class":108,"line":444},60,[106,446,447],{},"[Win32Focus]::SetForegroundWindow($hwnd)\n",[106,449,451],{"class":108,"line":450},61,[106,452,131],{"emptyLinePlaceholder":130},[106,454,456],{"class":108,"line":455},62,[106,457,458],{},"# 少し待ってフォーカスが安定するのを待つ\n",[106,460,462],{"class":108,"line":461},63,[106,463,464],{},"Start-Sleep -Milliseconds 200\n",[106,466,468],{"class":108,"line":467},64,[106,469,131],{"emptyLinePlaceholder":130},[106,471,473],{"class":108,"line":472},65,[106,474,475],{},"# --- ペインフォーカス移動 ---\n",[106,477,479],{"class":108,"line":478},66,[106,480,481],{},"# 環境変数 PANE_POS に基づいて対象ペインにフォーカスを移す\n",[106,483,485],{"class":108,"line":484},67,[106,486,487],{},"# 戦略: まず確実に左上に移動（←↑連打）してから目的のペインへ移動\n",[106,489,491],{"class":108,"line":490},68,[106,492,493],{},"$panePos = $env:PANE_POS\n",[106,495,497],{"class":108,"line":496},69,[106,498,499],{},"if (-not $panePos) {\n",[106,501,503],{"class":108,"line":502},70,[106,504,505],{},"    # PANE_POS 未設定の場合はウィンドウ最前面化のみで終了\n",[106,507,509],{"class":108,"line":508},71,[106,510,511],{},"    Write-Host \"PANE_POS が未設定のため、ウィンドウ最前面化のみ実行しました\"\n",[106,513,515],{"class":108,"line":514},72,[106,516,517],{},"    exit 0\n",[106,519,521],{"class":108,"line":520},73,[106,522,243],{},[106,524,526],{"class":108,"line":525},74,[106,527,131],{"emptyLinePlaceholder":130},[106,529,531],{"class":108,"line":530},75,[106,532,533],{},"# WScript.Shell の SendKeys を使って Alt+矢印 を送信\n",[106,535,537],{"class":108,"line":536},76,[106,538,539],{},"$wsh = New-Object -ComObject WScript.Shell\n",[106,541,543],{"class":108,"line":542},77,[106,544,131],{"emptyLinePlaceholder":130},[106,546,548],{"class":108,"line":547},78,[106,549,550],{},"# まず左上にリセット（最大2回ずつ送れば確実に左上に到達する）\n",[106,552,554],{"class":108,"line":553},79,[106,555,556],{},"Start-Sleep -Milliseconds 100\n",[106,558,560],{"class":108,"line":559},80,[106,561,562],{},"$wsh.SendKeys(\"%{LEFT}\")   # Alt+Left\n",[106,564,566],{"class":108,"line":565},81,[106,567,568],{},"Start-Sleep -Milliseconds 50\n",[106,570,572],{"class":108,"line":571},82,[106,573,562],{},[106,575,577],{"class":108,"line":576},83,[106,578,568],{},[106,580,582],{"class":108,"line":581},84,[106,583,584],{},"$wsh.SendKeys(\"%{UP}\")     # Alt+Up\n",[106,586,588],{"class":108,"line":587},85,[106,589,568],{},[106,591,593],{"class":108,"line":592},86,[106,594,584],{},[106,596,598],{"class":108,"line":597},87,[106,599,568],{},[106,601,603],{"class":108,"line":602},88,[106,604,131],{"emptyLinePlaceholder":130},[106,606,608],{"class":108,"line":607},89,[106,609,610],{},"# 目的のペインに移動\n",[106,612,614],{"class":108,"line":613},90,[106,615,616],{},"switch ($panePos) {\n",[106,618,620],{"class":108,"line":619},91,[106,621,622],{},"    \"top-left\" {\n",[106,624,626],{"class":108,"line":625},92,[106,627,628],{},"        # 既に左上にいるので何もしない\n",[106,630,632],{"class":108,"line":631},93,[106,633,634],{},"    }\n",[106,636,638],{"class":108,"line":637},94,[106,639,640],{},"    \"top-right\" {\n",[106,642,644],{"class":108,"line":643},95,[106,645,646],{},"        $wsh.SendKeys(\"%{RIGHT}\")  # Alt+Right\n",[106,648,650],{"class":108,"line":649},96,[106,651,634],{},[106,653,655],{"class":108,"line":654},97,[106,656,657],{},"    \"bottom-left\" {\n",[106,659,661],{"class":108,"line":660},98,[106,662,663],{},"        $wsh.SendKeys(\"%{DOWN}\")   # Alt+Down\n",[106,665,667],{"class":108,"line":666},99,[106,668,634],{},[106,670,672],{"class":108,"line":671},100,[106,673,674],{},"    \"bottom-right\" {\n",[106,676,678],{"class":108,"line":677},101,[106,679,646],{},[106,681,683],{"class":108,"line":682},102,[106,684,685],{},"        Start-Sleep -Milliseconds 50\n",[106,687,689],{"class":108,"line":688},103,[106,690,663],{},[106,692,694],{"class":108,"line":693},104,[106,695,634],{},[106,697,699],{"class":108,"line":698},105,[106,700,701],{},"    default {\n",[106,703,705],{"class":108,"line":704},106,[106,706,707],{},"        Write-Warning \"不明な PANE_POS: $panePos (top-left / top-right / bottom-left / bottom-right を指定してください)\"\n",[106,709,711],{"class":108,"line":710},107,[106,712,634],{},[106,714,716],{"class":108,"line":715},108,[106,717,243],{},[106,719,721],{"class":108,"line":720},109,[106,722,131],{"emptyLinePlaceholder":130},[106,724,726],{"class":108,"line":725},110,[106,727,728],{},"Write-Host \"フォーカス移動完了: $panePos\"\n",[27,730,732],{"id":731},"step-2-notification-フックの設定","Step 2: notification フックの設定",[18,734,735,738],{},[22,736,737],{},".claude/hooks.json"," （グローバル設定）に以下を追加する。既存の音声通知フックとは別エントリで追加すること。",[18,740,741],{},[91,742,743],{},"既存の hooks.json に追記するパターン:",[67,745,749],{"className":746,"code":747,"language":748,"meta":75,"style":75},"language-json shiki shiki-themes vitesse-light vitesse-light","{\n  \"hooks\": {\n    \"notification\": [\n      // ... 既存の音声通知フックはそのまま残す ...\n      {\n        \"command\": \"pwsh -NoProfile -File \\\"$HOME/.claude/scripts/auto-focus.ps1\\\"\",\n        \"description\": \"通知時にWindows Terminalを最前面にし、該当ペインにフォーカスを当てる\"\n      }\n    ]\n  }\n}\n","json",[22,750,751,757,776,790,796,801,835,854,859,864,869],{"__ignoreMap":75},[106,752,753],{"class":108,"line":109},[106,754,756],{"class":755},"shFtX","{\n",[106,758,759,763,767,770,773],{"class":108,"line":115},[106,760,762],{"class":761},"sqvqQ","  \"",[106,764,766],{"class":765},"sz8Xr","hooks",[106,768,769],{"class":761},"\"",[106,771,772],{"class":755},":",[106,774,775],{"class":755}," {\n",[106,777,778,781,783,785,787],{"class":108,"line":121},[106,779,780],{"class":761},"    \"",[106,782,24],{"class":765},[106,784,769],{"class":761},[106,786,772],{"class":755},[106,788,789],{"class":755}," [\n",[106,791,792],{"class":108,"line":127},[106,793,795],{"class":794},"sxvE3","      // ... 既存の音声通知フックはそのまま残す ...\n",[106,797,798],{"class":108,"line":134},[106,799,800],{"class":755},"      {\n",[106,802,803,806,809,811,813,817,821,825,828,830,832],{"class":108,"line":140},[106,804,805],{"class":761},"        \"",[106,807,808],{"class":765},"command",[106,810,769],{"class":761},[106,812,772],{"class":755},[106,814,816],{"class":815},"sMJiu"," \"",[106,818,820],{"class":819},"sdGka","pwsh -NoProfile -File ",[106,822,824],{"class":823},"snbK4","\\\"",[106,826,827],{"class":819},"$HOME/.claude/scripts/auto-focus.ps1",[106,829,824],{"class":823},[106,831,769],{"class":815},[106,833,834],{"class":755},",\n",[106,836,837,839,842,844,846,848,851],{"class":108,"line":146},[106,838,805],{"class":761},[106,840,841],{"class":765},"description",[106,843,769],{"class":761},[106,845,772],{"class":755},[106,847,816],{"class":815},[106,849,850],{"class":819},"通知時にWindows Terminalを最前面にし、該当ペインにフォーカスを当てる",[106,852,853],{"class":815},"\"\n",[106,855,856],{"class":108,"line":152},[106,857,858],{"class":755},"      }\n",[106,860,861],{"class":108,"line":158},[106,862,863],{"class":755},"    ]\n",[106,865,866],{"class":108,"line":164},[106,867,868],{"class":755},"  }\n",[106,870,871],{"class":108,"line":170},[106,872,243],{"class":755},[874,875,876],"blockquote",{},[18,877,878,94,881,884,885,888],{},[91,879,880],{},"注意:",[22,882,883],{},"hooks.json"," の正確な書式は Claude Code のバージョンに依存する。",[22,886,887],{},"/hooks"," コマンドで既存の設定を確認し、それに合わせて追記すること。",[27,890,892],{"id":891},"step-3-各ペインで環境変数を設定","Step 3: 各ペインで環境変数を設定",[18,894,895],{},"各ペインの起動時に、ペイン位置を示す環境変数をセットする。",[897,898,900],"h4",{"id":899},"方法a-手動設定シンプル","方法A: 手動設定（シンプル）",[18,902,903],{},"各ペインで Claude Code を起動する前に以下を実行:",[67,905,907],{"className":100,"code":906,"language":102,"meta":75,"style":75},"# 左上ペイン\n$env:PANE_POS = \"top-left\"\n\n# 右上ペイン\n$env:PANE_POS = \"top-right\"\n\n# 左下ペイン\n$env:PANE_POS = \"bottom-left\"\n\n# 右下ペイン\n$env:PANE_POS = \"bottom-right\"\n",[22,908,909,914,919,923,928,933,937,942,947,951,956],{"__ignoreMap":75},[106,910,911],{"class":108,"line":109},[106,912,913],{},"# 左上ペイン\n",[106,915,916],{"class":108,"line":115},[106,917,918],{},"$env:PANE_POS = \"top-left\"\n",[106,920,921],{"class":108,"line":121},[106,922,131],{"emptyLinePlaceholder":130},[106,924,925],{"class":108,"line":127},[106,926,927],{},"# 右上ペイン\n",[106,929,930],{"class":108,"line":134},[106,931,932],{},"$env:PANE_POS = \"top-right\"\n",[106,934,935],{"class":108,"line":140},[106,936,131],{"emptyLinePlaceholder":130},[106,938,939],{"class":108,"line":146},[106,940,941],{},"# 左下ペイン\n",[106,943,944],{"class":108,"line":152},[106,945,946],{},"$env:PANE_POS = \"bottom-left\"\n",[106,948,949],{"class":108,"line":158},[106,950,131],{"emptyLinePlaceholder":130},[106,952,953],{"class":108,"line":164},[106,954,955],{},"# 右下ペイン\n",[106,957,958],{"class":108,"line":170},[106,959,960],{},"$env:PANE_POS = \"bottom-right\"\n",[897,962,964],{"id":963},"方法b-起動スクリプトで自動化","方法B: 起動スクリプトで自動化",[18,966,967],{},"以下のスクリプトで4ペインを一括起動し、環境変数も自動セットする。",[18,969,970,94,972],{},[91,971,93],{},[22,973,974],{},"~/.claude/scripts/launch-4pane.ps1",[67,976,978],{"className":100,"code":977,"language":102,"meta":75,"style":75},"# launch-4pane.ps1\n# Windows Terminal で4分割ペインを立ち上げ、各ペインに PANE_POS を設定する\n#\n# 使い方: pwsh -File ~/.claude/scripts/launch-4pane.ps1\n#\n# 必要に応じてプロジェクトパスを変更すること\n\nparam(\n    [string]$Project1 = \".\",\n    [string]$Project2 = \".\",\n    [string]$Project3 = \".\",\n    [string]$Project4 = \".\"\n)\n\n# Windows Terminal の `wt` コマンドで4ペイン起動\n# セミコロン区切りで split-pane を連結する\nwt new-tab --title \"CC:top-left\" `\n    pwsh -NoExit -Command \"`$env:PANE_POS='top-left'; cd '$Project1'\" `; `\n  split-pane --horizontal --title \"CC:bottom-left\" `\n    pwsh -NoExit -Command \"`$env:PANE_POS='bottom-left'; cd '$Project3'\" `; `\n  move-focus up `; `\n  split-pane --vertical --title \"CC:top-right\" `\n    pwsh -NoExit -Command \"`$env:PANE_POS='top-right'; cd '$Project2'\" `; `\n  move-focus down `; `\n  split-pane --vertical --title \"CC:bottom-right\" `\n    pwsh -NoExit -Command \"`$env:PANE_POS='bottom-right'; cd '$Project4'\"\n\nWrite-Host \"4ペイン起動完了。各ペインで claude を起動してください。\"\n",[22,979,980,985,990,995,1000,1004,1009,1013,1018,1023,1028,1033,1038,1043,1047,1052,1057,1062,1067,1072,1077,1082,1087,1092,1097,1102,1107,1111],{"__ignoreMap":75},[106,981,982],{"class":108,"line":109},[106,983,984],{},"# launch-4pane.ps1\n",[106,986,987],{"class":108,"line":115},[106,988,989],{},"# Windows Terminal で4分割ペインを立ち上げ、各ペインに PANE_POS を設定する\n",[106,991,992],{"class":108,"line":121},[106,993,994],{},"#\n",[106,996,997],{"class":108,"line":127},[106,998,999],{},"# 使い方: pwsh -File ~/.claude/scripts/launch-4pane.ps1\n",[106,1001,1002],{"class":108,"line":134},[106,1003,994],{},[106,1005,1006],{"class":108,"line":140},[106,1007,1008],{},"# 必要に応じてプロジェクトパスを変更すること\n",[106,1010,1011],{"class":108,"line":146},[106,1012,131],{"emptyLinePlaceholder":130},[106,1014,1015],{"class":108,"line":152},[106,1016,1017],{},"param(\n",[106,1019,1020],{"class":108,"line":158},[106,1021,1022],{},"    [string]$Project1 = \".\",\n",[106,1024,1025],{"class":108,"line":164},[106,1026,1027],{},"    [string]$Project2 = \".\",\n",[106,1029,1030],{"class":108,"line":170},[106,1031,1032],{},"    [string]$Project3 = \".\",\n",[106,1034,1035],{"class":108,"line":176},[106,1036,1037],{},"    [string]$Project4 = \".\"\n",[106,1039,1040],{"class":108,"line":181},[106,1041,1042],{},")\n",[106,1044,1045],{"class":108,"line":186},[106,1046,131],{"emptyLinePlaceholder":130},[106,1048,1049],{"class":108,"line":192},[106,1050,1051],{},"# Windows Terminal の `wt` コマンドで4ペイン起動\n",[106,1053,1054],{"class":108,"line":197},[106,1055,1056],{},"# セミコロン区切りで split-pane を連結する\n",[106,1058,1059],{"class":108,"line":202},[106,1060,1061],{},"wt new-tab --title \"CC:top-left\" `\n",[106,1063,1064],{"class":108,"line":208},[106,1065,1066],{},"    pwsh -NoExit -Command \"`$env:PANE_POS='top-left'; cd '$Project1'\" `; `\n",[106,1068,1069],{"class":108,"line":213},[106,1070,1071],{},"  split-pane --horizontal --title \"CC:bottom-left\" `\n",[106,1073,1074],{"class":108,"line":218},[106,1075,1076],{},"    pwsh -NoExit -Command \"`$env:PANE_POS='bottom-left'; cd '$Project3'\" `; `\n",[106,1078,1079],{"class":108,"line":224},[106,1080,1081],{},"  move-focus up `; `\n",[106,1083,1084],{"class":108,"line":229},[106,1085,1086],{},"  split-pane --vertical --title \"CC:top-right\" `\n",[106,1088,1089],{"class":108,"line":234},[106,1090,1091],{},"    pwsh -NoExit -Command \"`$env:PANE_POS='top-right'; cd '$Project2'\" `; `\n",[106,1093,1094],{"class":108,"line":240},[106,1095,1096],{},"  move-focus down `; `\n",[106,1098,1099],{"class":108,"line":246},[106,1100,1101],{},"  split-pane --vertical --title \"CC:bottom-right\" `\n",[106,1103,1104],{"class":108,"line":252},[106,1105,1106],{},"    pwsh -NoExit -Command \"`$env:PANE_POS='bottom-right'; cd '$Project4'\"\n",[106,1108,1109],{"class":108,"line":257},[106,1110,131],{"emptyLinePlaceholder":130},[106,1112,1113],{"class":108,"line":263},[106,1114,1115],{},"Write-Host \"4ペイン起動完了。各ペインで claude を起動してください。\"\n",[18,1117,1118],{},[91,1119,1120],{},"使用例:",[67,1122,1124],{"className":100,"code":1123,"language":102,"meta":75,"style":75},"# 4つのプロジェクトを指定して起動\npwsh -File ~/.claude/scripts/launch-4pane.ps1 `\n    -Project1 \"C:\\Users\\numbe\\Git_repo\\mdx-playground\" `\n    -Project2 \"C:\\Users\\numbe\\Git_repo\\chrome-extension-MF\" `\n    -Project3 \"C:\\Users\\numbe\\Git_repo\\project3\" `\n    -Project4 \"C:\\Users\\numbe\\Git_repo\\project4\"\n",[22,1125,1126,1131,1136,1141,1146,1151],{"__ignoreMap":75},[106,1127,1128],{"class":108,"line":109},[106,1129,1130],{},"# 4つのプロジェクトを指定して起動\n",[106,1132,1133],{"class":108,"line":115},[106,1134,1135],{},"pwsh -File ~/.claude/scripts/launch-4pane.ps1 `\n",[106,1137,1138],{"class":108,"line":121},[106,1139,1140],{},"    -Project1 \"C:\\Users\\numbe\\Git_repo\\mdx-playground\" `\n",[106,1142,1143],{"class":108,"line":127},[106,1144,1145],{},"    -Project2 \"C:\\Users\\numbe\\Git_repo\\chrome-extension-MF\" `\n",[106,1147,1148],{"class":108,"line":134},[106,1149,1150],{},"    -Project3 \"C:\\Users\\numbe\\Git_repo\\project3\" `\n",[106,1152,1153],{"class":108,"line":140},[106,1154,1155],{},"    -Project4 \"C:\\Users\\numbe\\Git_repo\\project4\"\n",[61,1157],{},[14,1159,1160],{"id":1160},"動作確認手順",[27,1162,1164],{"id":1163},"_1-スクリプト単体テスト","1. スクリプト単体テスト",[67,1166,1168],{"className":100,"code":1167,"language":102,"meta":75,"style":75},"# 左上ペインにいると仮定してテスト\n$env:PANE_POS = \"top-left\"\n\n# Chrome など別ウィンドウにフォーカスを移してから実行\nStart-Sleep -Seconds 3  # 3秒以内に別ウィンドウをクリック\npwsh -NoProfile -File \"$HOME/.claude/scripts/auto-focus.ps1\"\n# → Windows Terminal が最前面に来て左上ペインにフォーカスが当たれば成功\n",[22,1169,1170,1175,1179,1183,1188,1193,1198],{"__ignoreMap":75},[106,1171,1172],{"class":108,"line":109},[106,1173,1174],{},"# 左上ペインにいると仮定してテスト\n",[106,1176,1177],{"class":108,"line":115},[106,1178,918],{},[106,1180,1181],{"class":108,"line":121},[106,1182,131],{"emptyLinePlaceholder":130},[106,1184,1185],{"class":108,"line":127},[106,1186,1187],{},"# Chrome など別ウィンドウにフォーカスを移してから実行\n",[106,1189,1190],{"class":108,"line":134},[106,1191,1192],{},"Start-Sleep -Seconds 3  # 3秒以内に別ウィンドウをクリック\n",[106,1194,1195],{"class":108,"line":140},[106,1196,1197],{},"pwsh -NoProfile -File \"$HOME/.claude/scripts/auto-focus.ps1\"\n",[106,1199,1200],{"class":108,"line":146},[106,1201,1202],{},"# → Windows Terminal が最前面に来て左上ペインにフォーカスが当たれば成功\n",[27,1204,1206],{"id":1205},"_2-フック経由テスト","2. フック経由テスト",[67,1208,1210],{"className":100,"code":1209,"language":102,"meta":75,"style":75},"# Claude Code セッション内で長時間かかるタスクを依頼し、\n# 別ウィンドウに切り替えて待機する\n# → タスク完了時に音声通知と同時にターミナルが最前面に来れば成功\n",[22,1211,1212,1217,1222],{"__ignoreMap":75},[106,1213,1214],{"class":108,"line":109},[106,1215,1216],{},"# Claude Code セッション内で長時間かかるタスクを依頼し、\n",[106,1218,1219],{"class":108,"line":115},[106,1220,1221],{},"# 別ウィンドウに切り替えて待機する\n",[106,1223,1224],{"class":108,"line":121},[106,1225,1226],{},"# → タスク完了時に音声通知と同時にターミナルが最前面に来れば成功\n",[61,1228],{},[14,1230,1231],{"id":1231},"トラブルシューティング",[27,1233,1235],{"id":1234},"windows-terminal-が最前面に来ない","Windows Terminal が最前面に来ない",[18,1237,1238,1241],{},[91,1239,1240],{},"原因:"," Windows のフォアグラウンドロック制約。Alt キーシミュレートが効いていない可能性。",[18,1243,1244],{},[91,1245,1246],{},"対策:",[31,1248,1249,1256,1259],{},[34,1250,1251,1252,1255],{},"スクリプト内の ",[22,1253,1254],{},"Start-Sleep"," の値を増やす（200ms → 500ms）",[34,1257,1258],{},"PowerShell を管理者権限で実行してみる",[34,1260,1261,1262,1265],{},"それでもダメな場合は ",[22,1263,1264],{},"FlashWindowEx","（タスクバー点滅）にフォールバックする:",[67,1267,1269],{"className":100,"code":1268,"language":102,"meta":75,"style":75},"# auto-focus.ps1 の SetForegroundWindow 後に追加\nAdd-Type @\"\nusing System;\nusing System.Runtime.InteropServices;\npublic class FlashHelper {\n    [StructLayout(LayoutKind.Sequential)]\n    public struct FLASHWINFO {\n        public uint cbSize;\n        public IntPtr hwnd;\n        public uint dwFlags;\n        public uint uCount;\n        public uint dwTimeout;\n    }\n    [DllImport(\"user32.dll\")]\n    public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);\n}\n\"@\n\n$flash = New-Object FlashHelper+FLASHWINFO\n$flash.cbSize = [System.Runtime.InteropServices.Marshal]::SizeOf($flash)\n$flash.hwnd = $hwnd\n$flash.dwFlags = 0x0003  # FLASHW_ALL (タスクバー + タイトルバー)\n$flash.uCount = 5\n$flash.dwTimeout = 0\n[FlashHelper]::FlashWindowEx([ref]$flash)\n",[22,1270,1271,1276,1280,1284,1288,1293,1298,1303,1308,1313,1318,1323,1328,1332,1336,1341,1345,1349,1353,1358,1363,1368,1373,1378,1383],{"__ignoreMap":75},[106,1272,1273],{"class":108,"line":109},[106,1274,1275],{},"# auto-focus.ps1 の SetForegroundWindow 後に追加\n",[106,1277,1278],{"class":108,"line":115},[106,1279,143],{},[106,1281,1282],{"class":108,"line":121},[106,1283,149],{},[106,1285,1286],{"class":108,"line":127},[106,1287,155],{},[106,1289,1290],{"class":108,"line":134},[106,1291,1292],{},"public class FlashHelper {\n",[106,1294,1295],{"class":108,"line":140},[106,1296,1297],{},"    [StructLayout(LayoutKind.Sequential)]\n",[106,1299,1300],{"class":108,"line":146},[106,1301,1302],{},"    public struct FLASHWINFO {\n",[106,1304,1305],{"class":108,"line":152},[106,1306,1307],{},"        public uint cbSize;\n",[106,1309,1310],{"class":108,"line":158},[106,1311,1312],{},"        public IntPtr hwnd;\n",[106,1314,1315],{"class":108,"line":164},[106,1316,1317],{},"        public uint dwFlags;\n",[106,1319,1320],{"class":108,"line":170},[106,1321,1322],{},"        public uint uCount;\n",[106,1324,1325],{"class":108,"line":176},[106,1326,1327],{},"        public uint dwTimeout;\n",[106,1329,1330],{"class":108,"line":181},[106,1331,634],{},[106,1333,1334],{"class":108,"line":186},[106,1335,167],{},[106,1337,1338],{"class":108,"line":192},[106,1339,1340],{},"    public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);\n",[106,1342,1343],{"class":108,"line":197},[106,1344,243],{},[106,1346,1347],{"class":108,"line":202},[106,1348,249],{},[106,1350,1351],{"class":108,"line":208},[106,1352,131],{"emptyLinePlaceholder":130},[106,1354,1355],{"class":108,"line":213},[106,1356,1357],{},"$flash = New-Object FlashHelper+FLASHWINFO\n",[106,1359,1360],{"class":108,"line":218},[106,1361,1362],{},"$flash.cbSize = [System.Runtime.InteropServices.Marshal]::SizeOf($flash)\n",[106,1364,1365],{"class":108,"line":224},[106,1366,1367],{},"$flash.hwnd = $hwnd\n",[106,1369,1370],{"class":108,"line":229},[106,1371,1372],{},"$flash.dwFlags = 0x0003  # FLASHW_ALL (タスクバー + タイトルバー)\n",[106,1374,1375],{"class":108,"line":234},[106,1376,1377],{},"$flash.uCount = 5\n",[106,1379,1380],{"class":108,"line":240},[106,1381,1382],{},"$flash.dwTimeout = 0\n",[106,1384,1385],{"class":108,"line":246},[106,1386,1387],{},"[FlashHelper]::FlashWindowEx([ref]$flash)\n",[27,1389,1390],{"id":1390},"ペインフォーカスが正しく移動しない",[18,1392,1393,1395],{},[91,1394,1240],{}," Windows Terminal のペインレイアウトがスクリプトの想定と異なる。",[18,1397,1398],{},[91,1399,1246],{},[31,1401,1402,1408],{},[34,1403,1404,1407],{},[22,1405,1406],{},"Alt+矢印"," のデフォルトキーバインドが変更されていないか確認",[34,1409,1410,1411,1414],{},"Windows Terminal の ",[22,1412,1413],{},"settings.json"," で以下が設定されているか確認:",[67,1416,1418],{"className":746,"code":1417,"language":748,"meta":75,"style":75},"{\n    \"actions\": [\n        { \"command\": { \"action\": \"moveFocus\", \"direction\": \"left\" }, \"keys\": \"alt+left\" },\n        { \"command\": { \"action\": \"moveFocus\", \"direction\": \"right\" }, \"keys\": \"alt+right\" },\n        { \"command\": { \"action\": \"moveFocus\", \"direction\": \"up\" }, \"keys\": \"alt+up\" },\n        { \"command\": { \"action\": \"moveFocus\", \"direction\": \"down\" }, \"keys\": \"alt+down\" }\n    ]\n}\n",[22,1419,1420,1424,1437,1510,1574,1638,1703,1707],{"__ignoreMap":75},[106,1421,1422],{"class":108,"line":109},[106,1423,756],{"class":755},[106,1425,1426,1428,1431,1433,1435],{"class":108,"line":115},[106,1427,780],{"class":761},[106,1429,1430],{"class":765},"actions",[106,1432,769],{"class":761},[106,1434,772],{"class":755},[106,1436,789],{"class":755},[106,1438,1439,1442,1444,1446,1448,1450,1453,1455,1458,1460,1462,1464,1467,1469,1472,1474,1477,1479,1481,1483,1486,1488,1491,1493,1496,1498,1500,1502,1505,1507],{"class":108,"line":121},[106,1440,1441],{"class":755},"        {",[106,1443,816],{"class":761},[106,1445,808],{"class":765},[106,1447,769],{"class":761},[106,1449,772],{"class":755},[106,1451,1452],{"class":755}," {",[106,1454,816],{"class":761},[106,1456,1457],{"class":765},"action",[106,1459,769],{"class":761},[106,1461,772],{"class":755},[106,1463,816],{"class":815},[106,1465,1466],{"class":819},"moveFocus",[106,1468,769],{"class":815},[106,1470,1471],{"class":755},",",[106,1473,816],{"class":761},[106,1475,1476],{"class":765},"direction",[106,1478,769],{"class":761},[106,1480,772],{"class":755},[106,1482,816],{"class":815},[106,1484,1485],{"class":819},"left",[106,1487,769],{"class":815},[106,1489,1490],{"class":755}," },",[106,1492,816],{"class":761},[106,1494,1495],{"class":765},"keys",[106,1497,769],{"class":761},[106,1499,772],{"class":755},[106,1501,816],{"class":815},[106,1503,1504],{"class":819},"alt+left",[106,1506,769],{"class":815},[106,1508,1509],{"class":755}," },\n",[106,1511,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1553,1555,1557,1559,1561,1563,1565,1567,1570,1572],{"class":108,"line":127},[106,1513,1441],{"class":755},[106,1515,816],{"class":761},[106,1517,808],{"class":765},[106,1519,769],{"class":761},[106,1521,772],{"class":755},[106,1523,1452],{"class":755},[106,1525,816],{"class":761},[106,1527,1457],{"class":765},[106,1529,769],{"class":761},[106,1531,772],{"class":755},[106,1533,816],{"class":815},[106,1535,1466],{"class":819},[106,1537,769],{"class":815},[106,1539,1471],{"class":755},[106,1541,816],{"class":761},[106,1543,1476],{"class":765},[106,1545,769],{"class":761},[106,1547,772],{"class":755},[106,1549,816],{"class":815},[106,1551,1552],{"class":819},"right",[106,1554,769],{"class":815},[106,1556,1490],{"class":755},[106,1558,816],{"class":761},[106,1560,1495],{"class":765},[106,1562,769],{"class":761},[106,1564,772],{"class":755},[106,1566,816],{"class":815},[106,1568,1569],{"class":819},"alt+right",[106,1571,769],{"class":815},[106,1573,1509],{"class":755},[106,1575,1576,1578,1580,1582,1584,1586,1588,1590,1592,1594,1596,1598,1600,1602,1604,1606,1608,1610,1612,1614,1617,1619,1621,1623,1625,1627,1629,1631,1634,1636],{"class":108,"line":134},[106,1577,1441],{"class":755},[106,1579,816],{"class":761},[106,1581,808],{"class":765},[106,1583,769],{"class":761},[106,1585,772],{"class":755},[106,1587,1452],{"class":755},[106,1589,816],{"class":761},[106,1591,1457],{"class":765},[106,1593,769],{"class":761},[106,1595,772],{"class":755},[106,1597,816],{"class":815},[106,1599,1466],{"class":819},[106,1601,769],{"class":815},[106,1603,1471],{"class":755},[106,1605,816],{"class":761},[106,1607,1476],{"class":765},[106,1609,769],{"class":761},[106,1611,772],{"class":755},[106,1613,816],{"class":815},[106,1615,1616],{"class":819},"up",[106,1618,769],{"class":815},[106,1620,1490],{"class":755},[106,1622,816],{"class":761},[106,1624,1495],{"class":765},[106,1626,769],{"class":761},[106,1628,772],{"class":755},[106,1630,816],{"class":815},[106,1632,1633],{"class":819},"alt+up",[106,1635,769],{"class":815},[106,1637,1509],{"class":755},[106,1639,1640,1642,1644,1646,1648,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678,1681,1683,1685,1687,1689,1691,1693,1695,1698,1700],{"class":108,"line":140},[106,1641,1441],{"class":755},[106,1643,816],{"class":761},[106,1645,808],{"class":765},[106,1647,769],{"class":761},[106,1649,772],{"class":755},[106,1651,1452],{"class":755},[106,1653,816],{"class":761},[106,1655,1457],{"class":765},[106,1657,769],{"class":761},[106,1659,772],{"class":755},[106,1661,816],{"class":815},[106,1663,1466],{"class":819},[106,1665,769],{"class":815},[106,1667,1471],{"class":755},[106,1669,816],{"class":761},[106,1671,1476],{"class":765},[106,1673,769],{"class":761},[106,1675,772],{"class":755},[106,1677,816],{"class":815},[106,1679,1680],{"class":819},"down",[106,1682,769],{"class":815},[106,1684,1490],{"class":755},[106,1686,816],{"class":761},[106,1688,1495],{"class":765},[106,1690,769],{"class":761},[106,1692,772],{"class":755},[106,1694,816],{"class":815},[106,1696,1697],{"class":819},"alt+down",[106,1699,769],{"class":815},[106,1701,1702],{"class":755}," }\n",[106,1704,1705],{"class":108,"line":146},[106,1706,863],{"class":755},[106,1708,1709],{"class":108,"line":152},[106,1710,243],{"class":755},[27,1712,1714],{"id":1713},"pane_pos-が引き継がれない","PANE_POS が引き継がれない",[18,1716,1717,1719],{},[91,1718,1240],{}," Claude Code がサブシェルで起動し、環境変数が引き継がれていない。",[18,1721,1722],{},[91,1723,1246],{},[31,1725,1726,1736],{},[34,1727,1728,1731,1732,1735],{},[22,1729,1730],{},"claude"," コマンド起動前に同じシェルで ",[22,1733,1734],{},"$env:PANE_POS"," をセットしているか確認",[34,1737,1738,1739,1742],{},"起動スクリプト（方法B）を使う場合は ",[22,1740,1741],{},"-NoExit"," フラグが付いているか確認",[61,1744],{},[14,1746,1747],{"id":1747},"ファイル構成",[67,1749,1752],{"className":1750,"code":1751,"language":72},[70],"~/.claude/\n├── hooks.json              # フック設定（既存に追記）\n└── scripts/\n    ├── auto-focus.ps1      # 自動フォーカススクリプト（新規）\n    └── launch-4pane.ps1    # 4ペイン一括起動スクリプト（任意）\n",[22,1753,1751],{"__ignoreMap":75},[61,1755],{},[14,1757,1759],{"id":1758},"補足-今後の拡張案","補足: 今後の拡張案",[31,1761,1762,1771,1780],{},[34,1763,1764,1767,1768,1770],{},[91,1765,1766],{},"Stream Deck 連携:"," 各ボタンに ",[22,1769,1406],{}," キーストロークを割り当て、手動でのペイン切り替えも高速化",[34,1772,1773,94,1776,1779],{},[91,1774,1775],{},"トースト通知との併用:",[22,1777,1778],{},"BurntToast"," PowerShell モジュールを使い、どのプロジェクトで完了したかをWindowsトースト通知で表示する（自動フォーカスが不要な場面用）",[34,1781,1782,1785,1786,1789],{},[91,1783,1784],{},"完了ペインの視覚的ハイライト:"," Windows Terminal の ",[22,1787,1788],{},"SetTabColor"," 等で、完了したペインのタブ色を変更する",[1791,1792,1793],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .shFtX, html code.shiki .shFtX{--shiki-default:#999999;--shiki-dark:#999999}html pre.shiki code .sqvqQ, html code.shiki .sqvqQ{--shiki-default:#99841877;--shiki-dark:#99841877}html pre.shiki code .sz8Xr, html code.shiki .sz8Xr{--shiki-default:#998418;--shiki-dark:#998418}html pre.shiki code .sxvE3, html code.shiki .sxvE3{--shiki-default:#A0ADA0;--shiki-dark:#A0ADA0}html pre.shiki code .sMJiu, html code.shiki .sMJiu{--shiki-default:#B5695977;--shiki-dark:#B5695977}html pre.shiki code .sdGka, html code.shiki .sdGka{--shiki-default:#B56959;--shiki-dark:#B56959}html pre.shiki code .snbK4, html code.shiki .snbK4{--shiki-default:#A65E2B;--shiki-dark:#A65E2B}",{"title":75,"searchDepth":115,"depth":115,"links":1795},[1796,1800,1801,1806,1810,1815,1816],{"id":16,"depth":115,"text":16,"children":1797},[1798,1799],{"id":29,"depth":121,"text":29},{"id":45,"depth":121,"text":45},{"id":65,"depth":115,"text":65},{"id":80,"depth":115,"text":80,"children":1802},[1803,1804,1805],{"id":83,"depth":121,"text":84},{"id":731,"depth":121,"text":732},{"id":891,"depth":121,"text":892},{"id":1160,"depth":115,"text":1160,"children":1807},[1808,1809],{"id":1163,"depth":121,"text":1164},{"id":1205,"depth":121,"text":1206},{"id":1231,"depth":115,"text":1231,"children":1811},[1812,1813,1814],{"id":1234,"depth":121,"text":1235},{"id":1390,"depth":121,"text":1390},{"id":1713,"depth":121,"text":1714},{"id":1747,"depth":115,"text":1747},{"id":1758,"depth":115,"text":1759},"dev","Claude Codeのnotificationフック発火時に、Windows Terminalを自動的に最前面に持ってきて該当ペインにフォーカスを当てる仕組みの実装手順。4分割ペインでの非同期セッション運用を効率化。","md",{},null,"/auto-focus-on-notification","claude-code-tools",false,"2026-03-25T00:00:00.000Z",{"title":5,"description":1818},"2026-03/2026-03-25/auto-focus-on-notification",[1829,1830,24,1831,1832,1833],"Windows Terminal","Claude Code","PowerShell","フック","開発環境","udOU7RzTwIG7MHmOCtkCd0gp4z08US8WBgNRj_nLA5k",[],"https://log.eurekapu.com/og/blog/auto-focus-on-notification.png?v=2026-03-25T00%3A00%3A00.000Z&title=Windows%20Terminal%20%E8%87%AA%E5%8B%95%E3%83%95%E3%82%A9%E3%83%BC%E3%82%AB%E3%82%B9%E5%AE%9F%E8%A3%85%E3%82%AC%E3%82%A4%E3%83%89&author=Kei%20Komatsu&sig=6ee9bb667f040798",1782528820560]