Remap Capslock to Esc and disable original Esc key in AutoHotkey - autohotkey

Remapping Capslock to Esc like so works:
Capslock::Esc
But when I add the following remappings (Esc, Alt-Esc, Ctrl-Esc):
Esc::
!Esc::
^Esc::
return
... for disabling the original Esc key, the Capslock remapping no longer works.
How can I remap Capslock to Esc and disable the original Esc key completely?
I hope you can help me, please.

As #vasili told, your Capslock goes to Esc, which is disabled.
From example in documentaition, I have found that, if you want to switch two keys you should write something like this:
a::b
b::a
So using this logic I tried to put some usually not used key:
Capslock::Esc
Esc::F15
^!Esc::F15
!Esc::F15
^Esc::F15
F1 through F24 - The 12 or more function keys at the top of most keyboards.

Here's an easier one using wildcard (*) and without mapping to unused key:
Capslock::Esc ; Remap Capslock to Esc
*Esc::return ; Disable Esc pressed with zero or any combination of modifiers
If it doesn't work, add a $ to block the trigger loop:
Capslock::Esc ; Remap Capslock to Esc
$*Esc::return ; Disable Esc pressed with zero or any combination of modifiers
To disable just certain combinations of Esc:
Capslock::Esc
$Esc::
$!Esc::
$^Esc::
return

Related

How to map CAPSLOCK to ESC and ESC to CAPSLOCK in Autohotkey?

So I want to map both keys:
Capslock to Esc
Esc to Capslock
And this script works for Capslock to Esc but it doesn't really work for Esc to Capslock. It causes a Capslock then Esc to be sent. I only want a Capslock sent:
Capslock::Esc
Esc::Capslock
Based on Griffin's Comment
$Capslock::Esc
$Esc::Capslock
The problem that you had was that one of the hotkeys you had was triggering another, which can be prevented by using the $ modifier.
From the docs:
This is usually only necessary if the script uses the Send command to
send the keys that comprise the hotkey itself, which might otherwise
cause it to trigger itself. The $ prefix forces the keyboard hook to
be used to implement this hotkey, which as a side-effect prevents the
Send command from triggering it. The $ prefix is equivalent to having
specified #UseHook somewhere above the definition of this hotkey.

Use hotkeys with function keys, modifier keys, and a letter keys

How can I use a hotkey that responds to pressing F24 & Shift D, for example? I want to press a function key (F#, not the key that is labeled "fn"), a modifier key, and a letter.
I am using a mouse with multiple side buttons; I'm using G Hub to send F24 when one of the mouse buttons is pressed. So I'm trying to have that mouse button act as another modifier key.
I'm able to do assign a hotkey with only F24 and a letter key. But I no matter what I try, I cannot do this with an added modifier key. When I try to run the script, I get the error "invalid key." I have tried this with the Shift key and with the Alt key, and neither will work.
This works:
F24 & D::MsgBox, hello
I've tried every alternat syntax shown in the documentation, but none of the following work.
F24 & {Alt} & D::MsgBox, hello
!{F42}D::
!{F42} & D::
F24 & ! & D::
{Alt} {F24} D::
F24 & +D::
Combinations of 3 or more hotkeys are not supported as described in the documentation you can use #if and GetKeyState
I don't know how are you generating F24 the following will work if you first press shift and then F12 and d if your keyboard generates F24 just replace F12 with F24
#if GetKeyState("Shift", "P")
F12 & d::MsgBox works
#If

Make a left Enter key with AutoHotkey, and also with a hot-key to resume the remapped key?

I'm thinking about to remap some key to behavior the Enter key for the left hand to easy access.
Then I find AutoHotkey and plan to map the Capslock key to Enter key. Also I need to resume to the Capslock key when I need it, so I also map the RAlt+Capslock to be the Capslock key.
However it doesn't work as expected. Anyone can give some advises?
Here's what I've tried:
Capslock::Enter
RAlt & Capslock::SendInput !{Capslock}
For now the second line can work but the first line doesn't work. When press the Capslock it doesn't send Enter key.
Try this
$CapsLock::Enter
RAlt & Capslock::SetCapsLockState, % GetKeyState("CapsLock", "T") ? "Off" : "On"

Autokey: Capslock and a character will not map to Left

I'm trying to use Capslock to modify hjkl to arrows to simulate vim but I keep getting an error.
Capslock & h::Left
I get an error:
Line Text: Left
Error: This line does not contain a recognised action
Capslock is later remapped to Esc.
If I use the mapping to fire off a new window it works without fault.
Is there a way to achieve this?
My keyboard doesn't have a left windows key so I cannot use the windows key.
Try this:
Capslock & h::send, {left}
It works for me this way.

In Eclipse Emacs mode, is there any way to remap or add the Alt key to the Esc key?

I'm used to the Emacs use of Esc for Metakey. In eclipse may I change the Esc key to be the Alt key?
Nope, I don't think there's a way to do that. The relevant Eclipse UI docs state:
The recognized modifiers keys are M1, M2, M3, M4, ALT, COMMAND, CTRL, and SHIFT.
ESC is only a "normal" key. Emacs handles ESC specifically, so that it acts like kind of a modifier.
On windows plateform you can use AutoHotkey to remap Esc to Alt
Just add this to your Autohotkey script :
#IfWinActive ahk_class SWT_Window0
$Esc::Alt
#IfWinActive
you may need to adjust the first line to match the class of your Eclipse window (use the windows spy tool provided in Autohokey).