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?

AutoHotkey v1でCapsLockを検出する方法

0
Posted at

概要

AutoHotkey v1で、無変換キーを押したあとにCapsLockキーを検出する方法をまとめる。

問題

次のようにCapsLockを終了キーへ指定しても、日本語キーボードでは反応しなかった。

Input, UserInput, L1, {CapsLock}

CapsLock/英数キーが、キー名では正しく認識されていなかった。

解決方法

CapsLockのスキャンコードSC03Aを指定する。

vk1D::HandleMuhenkanInput()

HandleMuhenkanInput()
{
    ; 次の1文字、またはCapsLockキーを待つ
    Input, UserInput, L1, {SC03A}

    if (ErrorLevel = "EndKey:SC03A")
    {
        Send, !{PrintScreen}
        return
    }

    switch UserInput
    {
        case "-":
            Send, !{PrintScreen}
    }
}

これで、次の入力を検出できる。

無変換キー
↓
CapsLock/英数キー
↓
Alt + PrintScreen

補足

キーコードは次のスクリプトで確認できる。

#InstallKeybdHook
KeyHistory

特殊キーが名前で反応しない場合は、KeyHistoryで確認したスキャンコードを指定するとよい。

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?