On one of my keyboard there is a physical switch that lets me change the capslock key to a function key (because capslock is a pretty useless key let's be honest) and I got used to this function.
My second keyboard doesn't have this option, so I use AHK to simulate this behaviour :
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetCapsLockState, AlwaysOff
CapsLock & Backspace::
Send, {Del}
Return
CapsLock & i::
Send, {Up}
Return
CapsLock & j::
Send, {Left}
Return
CapsLock & k::
Send, {Down}
Return
CapsLock & l::
Send, {Right}
Return
CapsLock & h::
Send, {Home}
Return
CapsLock & n::
Send, {End}
Return
CapsLock & s::
Send, {Volume_Down}
Return
CapsLock & d::
Send, {Volume_Up}
Return
CapsLock & a::
Send, {Volume_Mute}
Return
CapsLock & 1::
Send, {F1}
Return
CapsLock & 2::
Send, {F2}
Return
CapsLock & 3::
Send, {F3}
Return
CapsLock & 4::
GetKeyState, state, Alt
if state = D
SendInput !{F4}
else
SendInput {F4}
Return
Return
CapsLock & 5::
Send, {F5}
Return
CapsLock & 6::
Send, {F6}
Return
CapsLock & 7::
Send, {F7}
Return
CapsLock & 8::
Send, {F8}
Return
CapsLock & 9::
Send, {F9}
Return
CapsLock & 0::
Send, {F10}
Return
CapsLock & -::
Send, {F11}
Return
CapsLock & =::
Send, {F12}
Return
But I've encountered a problem. When I use PuTTY, it's like the PuTTY terminal captures the keystrokes before AHK.
For example when I press CapsLock + J, it write "J" in the terminal instead of sending {Left}
Is there a way to force AHK to capture all the keystrokes before any application ?
Thanks for your help !