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?

環境構築まとめ for NOCオペレーション

0
Last updated at Posted at 2026-06-30

はじめに

日常業務を効率化して空き時間に資格勉強をしたい。
TeraTermやRloginではなく、WSL2をターミナルとして使っている方を対象としている。

Keyboard Manager - テキスト送信

💡監視停止等のテンプレートはF24などショートカットキーへ割り当てて保存しておく。

Ctrl + Shift + M     // F24

rcsdiff -u           // Tab(FN6) + Q
make check           // Tab(FN6) + W
ci -u                // Tab(FN6) + E
preloadcheck.sh      // Tab(FN6) + R

対応します            // Tab(FN7) + A
確認します            // Tab(FN7) + S
対応不要              // Tab(FN7) + D

テンプレートA         // FN(FN5) + L-Ctrl
テンプレートB         // FN(FN5) + L-Win
テンプレートC         // FN(FN5) + L-Alt
テンプレートD         // FN(FN5) + L-Space

@                    // FN(FN5) + L-Alt
:                    // FN(FN5) + L-Ctrl

- [ ]                // -
[]()                 // =

{{{                  // [
}}}                  // ]

|  |  |              // \
| --- | --- |
|  |  |

```                  // `

<table>                            // T
  <tr>
    <th></th>
    <td></td>
  </tr>
</table>

<ins></ins>                                                           // U
<img src="image.png" style="max-width: 80%; max-width: 1000px;">     // I

<pre><code></code></pre>                                           // P

<a href="リダイレクタ=外部URL"></a>  [text] [text]: #link          // A
<sup></sup> <sub></sub>                                         // S
<details><summary></summary></details>                         // D
<font color="red"></font>                                     // F

> [!NOTE] [!TIP] [!IMPORTANT] [!WARNING] [!CAUTION]         // H
> body

<ul>                                                     // L
  <li><input type="checkbox"></li>
  <li><input type="checkbox"></li>
</ul>

<ol>
  <li><input type="checkbox"></li>
  <li><input type="checkbox"></li>
</ol>

<br>                                             // Enter

$\color{red}{\textbf{body}}$                   // C

<b></b>                                      // B

Keyboard Manager - EXEシリーズ

  • プログラムパス(環境により異なるので都度修正する
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • 引数(yyyy/mm/dd hh:mm
割り当て(FN5 + R-Ctrl)
==========================================
-WindowStyle Hidden -NoProfile -Command "Get-Date -Format 'yyyy/MM/dd HH:mm' | Set-Clipboard"
  • 引数(hh:mm
割り当て(FN5 + Win)
==========================================
-WindowStyle Hidden -NoProfile -Command "Get-Date -Format 'HH:mm' | Set-Clipboard"
  • 引数(ISO8601拡張形式 -> Splank, kibana, Garafanaなど)
割り当て(FN5 + R-Alt)
==========================================
-WindowStyle Hidden -NoProfile -Command "Get-Date -Format 'yyyy-MM-ddTHH:mm:ss.fff+09:00' | Set-Clipboard"
  • 引数(メモ帳、エクスプローラーを開く
割り当て(FN5 + M)
==========================================
-WindowStyle Hidden -NoProfile -Command "Start-Process notepad.exe; Start-Process explorer.exe"

Windowsファイル配置(Loopback.ps1

💡ユーザーディレクトリ直下へ配置する

$code = @"
using System.Runtime.InteropServices;
public class KeySender {
    [DllImport("user32.dll")]
    public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
    
    public static void SendKey() {
        keybd_event(0x17, 0, 0, 0);
        keybd_event(0x17, 0, 0x0002, 0);
    }
}
"@

Add-Type -TypeDefinition $code

while ($true) {
    [KeySender]::SendKey()
    Start-Sleep -Seconds 240
}

WSL2設定(.bashrc

💡ファイルパス(特にユーザー名)を個々の設定に合わせて変更する

cat << 'EOF' >> ~/.bashrc

W_PATH='C:\Users\ユーザー名\Loopback.ps1'

_pid() { powershell.exe -NoProfile -Command "(Get-CimInstance Win32_Process | ? {\$_.CommandLine -match 'Loopback\.ps1'} | Select -First 1).ProcessId" 2>/dev/null | tr -d '\r\n'; }

keep1() { p=$(_pid); [ -n "$p" ] && echo "実行中:$p" || { powershell.exe -NoProfile -Command "Start-Process pwsh -WindowStyle Hidden -ArgumentList '-WindowStyle','Hidden','-ExecutionPolicy','Bypass','-File','$W_PATH'"; echo "起動しました"; }; }
keep2() { p=$(_pid); [ -n "$p" ] && echo "実行中:$p" || echo "停止中"; }
keep3() { p=$(_pid); [ -n "$p" ] && taskkill.exe /F /PID $p >/dev/null 2>&1 && echo "停止:$p" || echo "停止中"; }

EOF

強制KeyUp送信バッチ for Nuphy's Bug

💡メモ帳へ貼り付けてデスクトップに保存する。

  • 文字コード:ANSI
  • ファイル名:ReleaseKeys.bat
@echo off
echo キーボードのスタック状態をリセット中...

powershell -NoProfile -Command "$code = 'using System; using System.Runtime.InteropServices; public class Key { [DllImport(\"user32.dll\")] public static extern void keybd_event(byte b, byte s, uint f, UIntPtr e); public static void Reset() { for(int i=1; i<=254; i++) keybd_event((byte)i, 0, 2, UIntPtr.Zero); } }'; Add-Type -TypeDefinition $code; [Key]::Reset()"

echo リセット完了
timeout /t 2 > nul

📍付録

文字入力コード確認用スクリプト(キーボード設定が壊れたとき

  • Powershellで実行しよう
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

# メインウィンドウ
$form = New-Object System.Windows.Forms.Form
$form.Text = "仮想キーコード チェッカー"
$form.Size = New-Object System.Drawing.Size(450, 400)
$form.StartPosition = "CenterScreen"
$form.TopMost = $true 

# 説明ラベル
$label = New-Object System.Windows.Forms.Label
$label.Text = "ボックスでキーを押下してください:"
$label.Font = New-Object System.Drawing.Font("Meiryo", 10)
$label.AutoSize = $true
$label.Location = New-Object System.Drawing.Point(10, 10)
$form.Controls.Add($label)

# 入力用テキストボックス
$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10, 40)
$textBox.Size = New-Object System.Drawing.Size(410, 50)
$textBox.Font = New-Object System.Drawing.Font("Consolas", 24, [System.Drawing.FontStyle]::Bold)
$form.Controls.Add($textBox)

# 結果表示用のリストボックス
$listBox = New-Object System.Windows.Forms.ListBox
$listBox.Location = New-Object System.Drawing.Point(10, 100)
$listBox.Size = New-Object System.Drawing.Size(410, 240)
$listBox.Font = New-Object System.Drawing.Font("Consolas", 12)
$form.Controls.Add($listBox)

# テキストボックスでキーが押された時の処理
$textBox.Add_KeyDown({
    $vkDec = $_.KeyValue               
    $vkHex = "0x{0:X2}" -f $vkDec      
    $keyName = $_.KeyCode              

    $msg = "キー: {0,-12} | 仮想キー: {1} ({2})" -f $keyName, $vkHex, $vkDec
    
    $listBox.Items.Insert(0, $msg)

    if ($listBox.Items.Count -gt 50) {
        $listBox.Items.RemoveAt(50)
    }
})

# キーを離した時にボックスの中身を空にする
$textBox.Add_KeyUp({
    $textBox.Text = ""
})

# 起動時に自動でテキストボックスにフォーカスを当てる
$form.Add_Shown({$textBox.Select()})

$form.ShowDialog()
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?