Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently I am using following code for changing keyboard layout:

//vim.ahk
CapsLock::Send, {CTRLDOWN}{SHIFTDOWN}{SHIFTUP}{CTRLUP}{CTRLUP}
    return
!^CapsLock::CapsLock

CapsLock & j  :: Send  {Down}
CapsLock & k  :: Send {Up}
CapsLock & h  :: Send {Left}
CapsLock & l  :: Send {right}
CapsLock & p  :: Send {PGUP}
CapsLock & `; :: Send {PGDN}
CapsLock & ^  :: Send {home}
CapsLock & $  :: Send {end}

Is this code stable enough? The problem is that sometimes CapsLock undesirably turns on

Upadet: I found out that CapsLock turn on when it is press with any key except above keys. (hkll;pae)

share|improve this question
1  
I use something extremely similar. What type of answer are you looking for? Have you run into issues when using this code? – Elliot DeNolf Nov 1 '12 at 12:35
    
I just want know is it in its optimal form or it can become better? – PHPst Nov 1 '12 at 12:59
    
Note that j in Vim is down and k is up. – echristopherson Nov 1 '12 at 21:53
    
@echristopherson Thanks, Corrected. – PHPst Nov 2 '12 at 3:39
    
1. When does Capslock turn on? 2. What is you Capslock:: mapping for used for? – William Bettridge-Radford Jan 14 '13 at 12:02
up vote 2 down vote accepted

add this to the top of your script.

SetCapsLockState, AlwaysOff

!^CapsLock::CapsLock

It should stop all Capslock events that you don't create.

http://www.autohotkey.com/docs/commands/SetNumScrollCapsLockState.htm

share|improve this answer
    
It was desirable that CapsLock could be turned on by using ctrl+shif+CapsLock, but I think keeping it always off is better than accidentally turning on. Thanks. – PHPst Jan 15 '13 at 3:49
    
That should still work. – William Bettridge-Radford Jan 15 '13 at 10:40
    
No, it does not work. – PHPst Jan 16 '13 at 7:07
    
It's working for me here. Can you try it with just those two lines in their own file? Maybe try +Capslock:Capslock as well. – William Bettridge-Radford Jan 16 '13 at 8:19
    
This does not work: SetCapsLockState, AlwaysOff !^CapsLock::CapsLock But this works: SetCapsLockState, AlwaysOff +Capslock::Capslock – PHPst Jan 16 '13 at 8:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .