Search code examples
windows-7autohotkeyctrlcapslock

How to swap Capslock and Ctrl without having capslock mode activated unintentionally?


I have a simple AutoHotKey script:

Capslock::Ctrl
#Capslock::Capslock 

The point is, occasionally the capslock mode is activated even though I only want it to function as Ctrl, and I can't make it stop. The only way to do that is suspense the script, fix it, then reactivate it.

How can I make it works as intended?


Key history

VK  SC  Type    Up/Dn   Elapsed Key     Window
----------------------------------------------
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.06    CapsLock        
14  03A h   d   0.03    CapsLock        
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.03    Control         
11  01D i   d   0.00    Control         
14  03A h   d   0.00    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   d   0.03    CapsLock        
11  01D i   d   0.00    Control         
14  03A h   u   0.03    CapsLock        
11  01D i   u   0.00    Control 

Solution

  • As said in the answer of johnlee, it can be because

    the script itself is too busy doing something else or the OS is not giving enough time slices to the script due to other tasks hogging the CPU

    so there is nothing else I can do. So my solution is

    #Space::Capslock

    Using Capslock::Ctrl is better than Capslock::SendInput {Blind}{Ctrl Down} because it doesn't activate Shift + Ctrl when Shift is pressed first.