- 最低限テキスト入力はホームポジションで出来るようにする
- ついでに一部のアプリケーションではCtrl-ReturnやShift-Tabが欲しいので適当に割り当てる
- Emacsなど一部のアプリケーションではスクリプトを動作させない
- よりシンプルに、より追加訂正しやすく
の考えでスクリプトを作ると以下のようになりました。
WindowsでEmacs風キーバインド - Usipediaを大いに参考にさせていただきました。
#MaxHotkeysPerInterval 300
#UseHook ;そのキー自身をSendしても無限ループにならないように
; キーバインドを無効にしたいウィンドウ
is_target()
{
IfWinActive,ahk_class ConsoleWindowClass ;Cygwin
Return 1
; IfWinActive,ahk_class MEADOW ;Meadow
; Return 1
; IfWinActive,ahk_class cygwin/x X rl-xterm-XTerm-0
; Return 1
; IfWinActive,ahk_class Vim ;Windows上のGVIM
; Return 1
; IfWinActive,ahk_class Xming ;X
; Return 1
; IfWinActive,ahk_class SunAwtFrame
; Return 1
IfWinActive,ahk_class Emacs ;NTEmacs
Return 1
; IfWinActive,ahk_class XEmacs ;Cygwin上のXEmacs
; Return 1
Return 0
}
imp(from,to)
{
; MsgBox %from%
; MsgBox %to%
if((is_target()))
Send,%from%
else
Send,%to%
}
func(to)
{
imp(A_ThisHotKey,to)
}
; 修飾キー一覧: http://ahk.xrea.jp/Hotkeys.html
; キーリスト: http://ahk.xrea.jp/KeyList.html
^i::func("{TAB}")
^m::func("{Return}")
^[::func("{ESC}")
^h::func("{BackSpace}")
^d::func("{DEL}")
!^m::func("^{Return}") ; Alt-Ctrl-m
+^i::func("+{TAB}") ; Shift-Ctrl-i