3

I've been using autoHotKeyrecently on a windows 8 machine and loving it. But I want to be able to press caps lock and turn the keyboard into a vim like command mode for moving the cursor, inserting and deleting easily in any program.

UPDATE (Thanks to @MCL for the help so far)

Im trying to use the following script but it wont change the behaviour based on the state

state := GetKeyState("Capslock", "T") 
if state
  j::Send,{Left}
  l::Send,{Right}
  i::Send,{Up}
  k::Send,{Down}
return
Damo
  • 5,698
  • 3
  • 37
  • 55
  • Cool story, bro. Is there a question somewhere? Something you've tried? Any precise problem you ran into? – MCL Dec 04 '14 at 09:35
  • Sorry, yes the problem is that i cant get AHK to change key functionality based on the presence of capslock being on. i can detect that capslock is currently being pressed but not that it is on or off. – Damo Dec 04 '14 at 09:40
  • Since you didn't provide any code, I can only guess that you're not using toggle mode. Read about it [here](http://ahkscript.org/docs/commands/GetKeyState.htm). – MCL Dec 04 '14 at 09:55

1 Answers1

6

Create context-sensitive hotkeys with #If:

#If GetKeyState("CapsLock", "T")=1

; The following hotkeys will only be effective if GetKeyState("CapsLock", "T")=1
j::Send,{Left}
l::Send,{Right}
i::Send,{Up}
k::Send,{Down}

#If ; end of #If
fxam
  • 3,874
  • 1
  • 22
  • 32