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

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

Related

Remap keys in loops

Background: I'm trying to have a f-mode and d-mode which means if I press down the f key and press another key like i then nothing happens excepts a shortcut. let say it will send Up key instead of f and I.
Issue: how I can remap a pressed key (I in my example) to a shortcut (Up as example)?
Code:
d::
f::{
;...
loop{
if !GetKeyState("f","p") && !GetKeyState("d","p"){
break
}
if GetKeyState("i","p") {
OutputDebug "i"
send "{up}"
continue
}
; ...
}
}
Looks like you want to make a custom combination.
From the Docs:
You can define a custom combination of two keys (except joystick
buttons) by using " & " between them. In the below example, you would
hold down Numpad0 then press the second key to trigger the hotkey:
Numpad0 & Numpad1::MsgBox You pressed Numpad1 while holding down Numpad0.
Numpad0 & Numpad2::Run Notepad
But also note:
The prefix key loses its native function: In the above example,
Numpad0 becomes a prefix key; but this also causes Numpad0 to lose its
original/native function when it is pressed by itself. To avoid this,
a script may configure Numpad0 to perform a new action such as one of
the following:
Numpad0::WinMaximize A ; Maximize the active/foreground window.
Numpad0::Send {Numpad0} ; Make the release of Numpad0 produce a Numpad0 keystroke. See comment below.
This is to prevent holding down a key from spamming inputs while you wait to press the second part of a key combination. So essentially, your 'f' and 'd' keys will now perform their normal functions when you release them instead of initially pressing them down.
Anyways, the code would become:
f & i::
d & i::
Send {Up}
return
f::f
d::d

Creating a hotkey with backslash in AutoHotkey

I want to create a hotkey using a backslash key (\). Namely, I would like to assign Media_Prev to Windows button + backslash. I have tried both LWin & \::Media_Prev and #\::Media_Prev. However, these do not work: it just normally sends the backslash character. In AutoHotkey's key history, I do see that both \ and LWin register when I press this key combination.
Interestingly, something like LWin & c::Media_Prev or #v::Media_Prev does work well, just not with the backslash character.
This worked for me, using AHK version 1.1.13.01
LWin & \:: run Notepad
you can also use scan codes - something like
SC15B & SC02B:: run Notepad
should have the same effect
reference: here
I successfully tested the following:
<#vk dc::Send {Media_Prev}
< is Left key
# is Windows key
VK DC is virtual key number DC (you can find this code using AHK menu View > Key History and Script Info). With VK, the same key works regardless of active keyboard layout.
Note: Don't do LWin & key or Ctrl & key etc... & has a bit different meaning. For the above purpose AHK provides prefixes as shown above, e.g. ^b or #F1 etc. See AHK help on Remapping Keys and Buttons

Remap Capslock to Esc and disable original Esc key in 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

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.