Autohotkey – Problem with Rebinding Ctrl to Capslock

autohotkey

I am using AutoHotkey to rebind Ctrl to Capslock like this:

Capslock::Ctrl

I have also bound my home keys for movement while Capslock is held:

^h::Send {LEFT}
^j::Send {DOWN}
^k::Send {UP}
^l::Send {RIGHT}

Trouble is, I can hold Capslock and issue one movement combo, but subsequent taps of h,j,k or l while still holding Capslock results in one of those letters appearing in my editor. In other words, it's as if Capslock is being released, even though I am still holding it down. If I hold the actual Ctrl key and use the movement bindings, it works fine. Anyone know how to rectify this?

Best Answer

The solution was kindly posted on the AutoHotKey forum by "VxE":

Capslock::
   Gui, 93:+Owner ; prevent display of taskbar button
   Gui, 93:Show, y-99999 NA, Enable nav-hotkeys: hjkl
   Send {LCtrl Down}
   KeyWait, Capslock ; wait until the Capslock button is released
   Gui, 93:Cancel
   Send, {LCtrl Up}
Return

#IfWinExist, Enable nav-hotkeys: hjkl

   *h::Send {Blind}{LCtrl Up}{Left}{LCtrl Down}
   *j::Send {Blind}{LCtrl Up}{Down}{LCtrl Down}
   *k::Send {Blind}{LCtrl Up}{Up}{LCtrl Down}
   *l::Send {Blind}{LCtrl Up}{Right}{LCtrl Down}

#IfWinExist, ; end context-sensitive block
Related Question