Hi,
I've got a problem rebinding Ctrl to Capslock. I posted a question on SuperUser but didn't get any responses that helped:
<!-- m -->http://superuser.com... ... autohotkey<!-- m -->
Does anyone know what the problem is here, and how to solve it?
Many thanks!
Charles
Problem rebinding Ctrl to Capslock using
Started by
charlesroper
, Aug 01 2010 07:08 PM
4 replies to this topic
#1
-
Posted 01 August 2010 - 07:08 PM
Using an activator key to enable other keys is a common use of AHK (iow: there are many examples on the forums)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?
The issue you're running into is that the Send command artificially releases modifier keys before sending the other key strokes.
Here's a different way to use hotkey-activated hotkeys. Note that the 'hjkl' hotkeys will only be enabled while capslock is held down
$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
#2
-
Posted 02 August 2010 - 12:23 AM
Thank you, that works perfectly. To aid my understanding, what is the purpose of those Gui commands?
BTW:
Sorry if I committed a faux pas there - I didn't want to post an unnecessary description of the problem when I had already written it elsewhere. I guess some folk can't access SuperUser, though, and having my question repeated here will aid forum searches, thus justifying the redundancy.
BTW:
what charlesroper should have wrote
Sorry if I committed a faux pas there - I didn't want to post an unnecessary description of the problem when I had already written it elsewhere. I guess some folk can't access SuperUser, though, and having my question repeated here will aid forum searches, thus justifying the redundancy.
#3
-
Posted 02 August 2010 - 08:08 AM
The GUI in that example is simply a way to 'trick' the AHK #IfWinExist into obeying part of the script, rather than another window.
Notice the title of the gui (parameter 3 of the 'Gui, Show...' command ) matches the title on the line with #IfWinExist.
The gui number (93) is arbitrary.
Notice the title of the gui (parameter 3 of the 'Gui, Show...' command ) matches the title on the line with #IfWinExist.
The gui number (93) is arbitrary.
#4
-
Posted 02 August 2010 - 10:16 AM