AutoHotKeyの設定変更

動機:

  • tigを使おうとした。
  • tigでは、^nキー と DownArrowキー は別なバインドを持つ。
  • AutoHotKyeのキーマップで、^n → DownArrow とマップしている。ダメだ。

対処:

  • tig を cmd.exe でのみ使う。
  • cmd.exe に対しては、キーマップをしない。

手順:

  • 常駐しているAutoHotKeyはタスクバーにいるので、右クリックで Window Spy を起動する。
  • Window Spy で cmd.exe のウィンドウ情報を知る。
    • ahk_class ConsoleWindowClass
    • ahk_exe cmd.exe
  • この情報をもとに HiyamaKeymap.ahk を書き換える。

コード:

次のような既存コードがある。

#If WinActive("ahk_class MozillaWindowClass") && WinActive("ahk_exe firefox.exe")
!b::Send ^!b
#If

次のような古いコードの事例がインターネットにあった。

#IfWinNotActive my task-management tool
!w::Send ^{F4}
#If

要するに、NOT WIN ACTIVE として cmd.exe のウィンドウを指定すればいいので。

#If !( WinActive("ahk_class ConsoleWindowClass") && WinActivate("ahk_exe cmd.exe") )
; ...
; ...
#If

の形にすればよい。実際には:

#If !( WinActive("ahk_class ConsoleWindowClass") && WinActive("ahk_exe cmd.exe") )
$^n::Send,{Down} ; new window
$^p::Send {Up} ; print
#If