I'm fairly new to AutoHotkey, so if something is written bad (chances are pretty high, since I mostly modified stuff from the manual), please tell me and I try to change it.
SINGLE & DOUBLE
This one is from the manual. It sends out a if pressed once and b if pressed twice.
Code: Select all
F20::
If (A_PriorHotKey = "F20" AND A_TimeSincePriorHotkey < 900){
SendInput, b ;DOUBLE - b
SetTimer, F20Default, Off
}Else
SetTimer, F20Default, -900
Return
F20Default:
SendInput, a ;SINGLE - a
Return
SHORT & LONG I
Sends out a if pressed short and b if pressed long. Both keys get send after releasing the button.
Code: Select all
F20::Return
F20 Up::
If (A_PriorHotKey = "F20" AND A_TimeSincePriorHotkey < 400)
SendInput, a ;SHORT - a
Else If (A_PriorHotKey = "F20" AND A_TimeSincePriorHotkey > 400)
SendInput, b ;LONG - b
Return
SHORT & LONG II
This one sends out a if pressed short and b if pressed long. The b gets send after 600ms are over, even if the button isn't yet released. The downside is, that the a button also needs 600ms, even if the button releases earlier, which makes it unusable for fast actions.
Code: Select all
F20::
f20_up = 0
SetTimer, KeyF20, 600
Return
F20 Up::
f20_up = 1
Return
KeyF20:
SetTimer, KeyF20, off
If (f20_up = 1)
SendInput, a ;SHORT - a
Else {
SendInput, b ;LONG - b
}
Return
TOGGLE
I guess this one is from the manual too. A simple a - b toggle
Code: Select all
F20::
toggle:=!toggle
if toggle
SendInput, a ;TOGGLE - a-b
Else
SendInput, b
Return
SINGLE DOUBLE LONG
This one sends a if you press short, b if your keep the button pressed and c if you double tab it.
Code: Select all
F20::
f20_up = 0
if f20_presses > 0
{
f20_presses += 1
Return
}
f20_presses = 1
SetTimer, KeyF20, 400
Return
F20 Up::
f20_up = 1
Return
KeyF20:
SetTimer, KeyF20, off
If f20_presses = 1
{
If (f20_up = 1)
SendInput, a ;SINGLE - a
Else
SendInput, b ;LONG - b
}
Else if f20_presses = 2
{
SendInput, c ;DOUBLE - c
}
f20_presses = 0
Return
SINGLE DOUBLE TRIPLE
This one is as it is from the manual. It sends out a if pressed one time, b if you double tab it and c if you press it three times in a row.
Code: Select all
F20::
If f20_presses > 0
{
f20_presses += 1
return
}
f20_presses = 1
SetTimer, KeyF20, 400
Return
KeyF20:
SetTimer, KeyF20, off
If f20_presses = 1
{
SendInput, a ;SINGLE - a
}
Else If f20_presses = 2
{
SendInput, b ;DOUBLE - b
}
Else If f20_presses > 2
{
SendInput, c ;TRIPLE - c
}
f20_presses = 0
Return
HOLD & SINGLE
Keeps Alt pressed if you keep the button pressed and sends out a if you press it shortly.
Code: Select all
F20::
f20_up = 0
f20_long = 0
SetTimer, KeyF20T, 400
Return
F20 Up::
f20_up = 1
if(f20_long = 1)
SendInput, {AltUp} ;RELEASE - Alt
Return
KeyF20T:
SetTimer, KeyF20T, off
If (f20_up = 1) {
SendInput, a ;SINGLE - a
}Else {
SendInput, {AltDown} ;HOLD - Alt
f20_long = 1
}
Return
HOLD & DOUBLE
Keeps Alt pressed if you keep the button pressed and sends out a if you double tab it.
Code: Select all
F20::
If (A_PriorHotKey = "F20 Up" AND A_TimeSincePriorHotkey < 300) {
SendInput, a ;DOUBLE - a
} Else {
SendInput, {AltDown} ;HOLD - Alt
}
Return
F20 Up::
If (A_PriorHotKey = "F20" AND A_TimeSincePriorHotkey > 300)
SendInput, {AltUp}
Return