How to assign a hotkey of quickly pressing {Alt} key twice in Autohotkey?
In other words: How to assign Press Alt+Release Alt+Press Alt as a hotkey?
In other words: How to assign key down {Alt} key then key up {Alt} key then quickly key down {Alt}?.
I want to set the time between releasing {Alt} key then pressing it again (to be very small) in order to activate hotkey.
• Example: if the user pressed {Alt} key then released it then waited for 5 seconds then pressed {Alt} key again, the hotkey shouldn't be working or active at all. But if he pressed {Alt} key again before 1.5 seconds, then the hotkey will work. I want to be able to set this time.
• Analogy: it's something like double clicking a mouse button and setting the time between 1st and second click in order for the double-click action to be triggered. But what I'm looking for instead is setting a double click for a keyboard key.
How to assign hotkey of pressing Alt key twice (Alt+Release+Alt) in Autohotkey? Topic is solved
Re: How to assign hotkey of pressing Alt key twice (Alt+Release+Alt) in Autohotkey?
Yes, try something like that:
Replace the MessageBoxes by useful code
Regards
Code: Select all
LAlt::
profile++
SetTimer check_profile, -800 ; 800 ms limit
return
check_profile:
if (profile = 1)
{
MsgBox, 1
}
if (profile = 2)
{
MsgBox, 2
}
if (profile = 3)
{
MsgBox, 3
}
profile = 0 ; Reset variable
return
Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Re: How to assign hotkey of pressing Alt key twice (Alt+Release+Alt) in Autohotkey?
Hallo,
try:
try:
Code: Select all
~LAlt:: ;~ prefix when the hotkey fires, its key's native function will not be blocked
IF !(A_TickCount < LAlt)
{
KeyWait, LAlt
LAlt := A_TickCount + 1500 ;1.5 seconds between releasing LAlt then pressing it again
Return
}
LAlt =
ToolTip, LAlt key twice
Return
Re: How to assign hotkey of pressing Alt key twice (Alt+Release+Alt) in Autohotkey?
See TapHoldManager
This will allow you to handle multi-tap / long-press etc for any number of keys (ie it supports tap-tap, tap-hold, tap-tap-hold etc)
FYI Rohdwedder's technique will only work for one key. If you try to use the same technique for two keys (eg ALT and CTRL) in the same script, his technique will not work properly if more than one key is held at once (Due to the use of KeyWait).
This will allow you to handle multi-tap / long-press etc for any number of keys (ie it supports tap-tap, tap-hold, tap-tap-hold etc)
FYI Rohdwedder's technique will only work for one key. If you try to use the same technique for two keys (eg ALT and CTRL) in the same script, his technique will not work properly if more than one key is held at once (Due to the use of KeyWait).
Re: How to assign hotkey of pressing Alt key twice (Alt+Release+Alt) in Autohotkey? Topic is solved
Thank you all for your suggestions.
Hope you and all your families are safe.
Sorry for the very late reply.
I have updated your code in order to support Window criteria specification and Pause/Resume/Remove hotkeys (GitHub Pull requests: 1, 2).
Also kindly find the updated code for TapHoldManager.ahk here: (or on GitHub)
Hope you and all your families are safe.
Sorry for the very late reply.
This is the best solution. Thank you a lot.evilC wrote: ↑24 Oct 2018, 04:58See TapHoldManager
This will allow you to handle multi-tap / long-press etc for any number of keys (ie it supports tap-tap, tap-hold, tap-tap-hold etc)
FYI Rohdwedder's technique will only work for one key. If you try to use the same technique for two keys (eg ALT and CTRL) in the same script, his technique will not work properly if more than one key is held at once (Due to the use of KeyWait).
I have updated your code in order to support Window criteria specification and Pause/Resume/Remove hotkeys (GitHub Pull requests: 1, 2).
Also kindly find the updated code for TapHoldManager.ahk here: (or on GitHub)
Code