Lexikos wrote:
Adding more modifiers to my previous script should be simple. Just add, for instance, an alt_key variable and do for it what's already done for shift_key and ctrl_key. However, at some point you'll hit the limitations of your keyboard hardware.
Hi Lexikos,
I have to confess that I am really stupid being stuck on thinking that, like your example code, the firing actions must contain the {left} for all modifiers, and the modifiers are only limited to being remapped to only one traditional modifiers (Shift, Control) whatever firing keys (j and the remaining letters) are pressed.
After your confirmation of more possibilities based on your code's structure, I tried to rewrite it and also got "half" success. Below is the code:
Code:
; Using CapsLock and LWin as arbitrary modifiers, and "j" and "k" as firing keys.
ctrl_key := "CapsLock"
shift_key := "LWin"
j_key := "j"
k_key := "k"
Hotkey *%ctrl_key%, mod_key
Hotkey *%ctrl_key% Up, mod_key
Hotkey *%shift_key%, mod_key
Hotkey *%shift_key% Up, mod_key
return
mod_key: ; Modifier key pressed or released.
kmods := ""
jmods := ""
if (GetKeyState(ctrl_key, "P") && !GetKeyState(shift_key, "P"))
{
kmods := "CLk"
jmods := "CLj"
}
if (GetKeyState(shift_key, "P") && !GetKeyState(ctrl_key, "P"))
{
kmods := "LWk"
jmods := "LWj"
}
if (GetKeyState(ctrl_key, "P") && GetKeyState(shift_key, "P"))
{
kmods := "LWCLk"
jmods := "LWCLj"
}
Hotkey %j_key%, j_key, % jmods ? "On" : "Off"
Hotkey %k_key%, k_key, % kmods ? "On" : "Off"
return
k_key:
SendRaw %kmods%
return
j_key: ; Modified key pressed (with at least one modifier).
SendRaw %jmods%
return
Why I said it was a "half" success is that the firing actions could not entirely get rid of the modifiers' native functions (which is LWin). When I fire the keys, letters printed are missing some of the assigned letters. When I press the LWin-related combinations AHK only prints some letters and Windows locks my desktop. Since the assigned letter and the missing letter are "l", this implies that the firing actions include native Win modifier action, combing "l" which fires "Win-l" and locks my computer.
However when I press CapsLock and LWin independently, they both react like they would have been disabled. I tried adding "CapsLock::Return" and "LWin::Return" but it would entirely disable the hotkey code too.
Therefore I would like to ask if there is any other way which could completely disable the original key functions. Thanks for your guidance.