Created
September 4, 2013 17:48
-
-
Save anonymous/6440330 to your computer and use it in GitHub Desktop.
trying to make single keys works but the double key presses seem to interfere?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
#SingleInstance Force | |
;double key short press and long press example: | |
n & h:: ;pressing s while holding down n is the hotkey | |
h & n:: ;pressing n while holding down s is the hotkey (optional) | |
CurrentTime := A_TickCount ;retrieve the current time | |
KeyWait, h ;wait for the tab key to be released | |
ElapsedTime := A_TickCount - CurrentTime ;retrieve the amount of time elapsed in milliseconds | |
If (ElapsedTime <= 250) ;250 milliseconds, or a quarter of a second | |
{ | |
send, h | |
} | |
Else | |
{ | |
send, g | |
key4 := "" | |
} | |
Return | |
n & m:: ;pressing m while holding down n is the hotkey | |
m & n:: ;pressing n while holding down m is the hotkey (optional) | |
CurrentTime := A_TickCount ;retrieve the current time | |
KeyWait, n ;wait for the tab key to be released | |
ElapsedTime := A_TickCount - CurrentTime ;retrieve the amount of time elapsed in milliseconds | |
If (ElapsedTime <= 250) ;250 milliseconds, or a quarter of a second | |
{ | |
send, t | |
} | |
Else ;time was more than or equal to 250 milliseconds, or a quarter of a second | |
{ | |
send, x | |
} | |
Return | |
j & m:: ;pressing d while holding down s is the hotkey | |
m & j:: ;pressing s while holding down d is the hotkey (optional) | |
CurrentTime := A_TickCount ;retrieve the current time | |
KeyWait, m ;wait for the tab key to be released | |
ElapsedTime := A_TickCount - CurrentTime ;retrieve the amount of time elapsed in milliseconds | |
If (ElapsedTime <= 250) ;250 milliseconds, or a quarter of a second | |
{ | |
send, r | |
} | |
Else ;time was more than or equal to 250 milliseconds, or a quarter of a second | |
{ | |
send, f | |
} | |
Return | |
h & j:: ;pressing d while holding down m is the hotkey | |
j & h:: ;pressing m while holding down d is the hotkey (optional) | |
CurrentTime := A_TickCount ;retrieve the current time | |
KeyWait, j | |
ElapsedTime := A_TickCount - CurrentTime ;retrieve the amount of time elapsed in milliseconds | |
If (ElapsedTime <= 250) ;250 milliseconds, or a quarter of a second | |
{ | |
send, lowJ | |
} | |
Else ;time was more than or equal to 250 milliseconds, or a quarter of a second | |
{ | |
send, j | |
} | |
Return | |
;SINGLE KEY - QUICK PRESS (less than .25 seconds) | |
$j:: | |
KeyWait, j ; Wait for n to b rlasd | |
;~ MsgBox % A_TimeSinceThisHotkey | |
x := A_TimeSinceThisHotkey ; Just assigning x here, for shorter "if's" | |
If (x < 250) ; If hotkey was held for less than 0.25 seconds, 250 ms | |
{ | |
Send e | |
} | |
else | |
{ | |
send y | |
} | |
return | |
$h:: | |
KeyWait, h ; Wait for n to b rlasd | |
;~ MsgBox % A_TimeSinceThisHotkey | |
x := A_TimeSinceThisHotkey ; Just assigning x here, for shorter "if's" | |
If (x < 250) ; If hotkey was held for less than 0.25 seconds, 250 ms | |
{ | |
Send i | |
} | |
else | |
{ | |
send y | |
} | |
return | |
$n:: | |
KeyWait, n ; Wait for n to b rlasd | |
;~ MsgBox % A_TimeSinceThisHotkey | |
x := A_TimeSinceThisHotkey ; Just assigning x here, for shorter "if's" | |
If (x < 250) ; If hotkey was held for less than 0.25 seconds, 250 ms | |
{ | |
Send o | |
} | |
else | |
{ | |
send w | |
} | |
return | |
$space:: | |
KeyWait, space ; Wait for n to b rlasd | |
;~ MsgBox % A_TimeSinceThisHotkey | |
x := A_TimeSinceThisHotkey ; Just assigning x here, for shorter "if's" | |
If (x < 250) ; If hotkey was held for less than 0.25 seconds, 250 ms | |
{ | |
Send {space} | |
} | |
else | |
{ | |
send longSpace | |
} | |
return | |
threshold = 500 | |
threshold2 = | |
m:: ; change to “tab” same effect | |
start := A_TickCount | |
while (GetKeyState(A_ThisHotkey)){ | |
if (A_TickCount - start) > threshold{ | |
{ | |
Send, A | |
sleep 550 | |
} | |
return | |
} | |
} | |
Send, a | |
return | |
esc::exitapp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment