AutoHotkey scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

97 lines
2.3 KiB

;
; Functions for holding and repeating keys
;
_HoldRepeat_TurboOn := Map()
_GetPrefix(SendBlind) {
if (SendBlind) {
return "{Blind}"
} else {
return ""
}
}
Hold(Primary, Secondary:=[],Tertiary:=[],SendBlind:=true) {
Prefix := _GetPrefix(SendBlind)
Send Prefix "{" Primary " down}"
SetTimer HoldLoop.Bind(Primary,Secondary,Tertiary,Prefix), 50
}
HoldLoop(Primary, Secondary, Tertiary,Prefix) {
if GetKeyState(Primary,"P") {
SetTimer , 0
return
}
for index,key in Secondary {
if GetKeyState(key,"P") {
Send Prefix "{" Primary " up}"
SetTimer , 0
return
}
}
keyHeld:=!Tertiary.Length
for index,key in Tertiary {
if GetKeyState(key,"P") {
keyHeld:=1
break
}
}
if (!keyHeld) {
Send Prefix "{" Primary " up}"
SetTimer , 0
return
}
}
Repeat(Primary, Secondary,SendBlind:=true) {
Prefix := _GetPrefix(SendBlind)
Send Prefix "{" Primary " up}"
Sleep 100
RepeatVar := 0
Loop {
if GetKeyState(Primary,"P") {
return
}
for index,key in Secondary {
if GetKeyState(key,"P") {
return
}
}
if (RepeatVar == 1) {
Send Prefix "{" Primary " down}"
RepeatVar := 0
} else {
Send Prefix "{" Primary " down}"
RepeatVar := 1
}
Sleep 100
}
}
; Sets key to hold if single tap, or repeat if double tap
HoldOrRepeat(Primary, Secondary,SendBlind:=True) {
Send _GetPrefix(SendBlind) "{" Primary " down}"
if KeyWait(Primary, "D T0.2") {
Repeat(Primary,Secondary,SendBlind)
} else {
Hold(Primary,Secondary,,SendBlind)
}
}
; Press Target button extremely rapidly while Hold button is held down
Turbo(Target,Hold:=Target) {
global _HoldRepeat_TurboOn
If (_HoldRepeat_TurboOn.Has(Target "_" Hold) and _HoldRepeat_TurboOn[Target "_" Hold]) {
return
} else {
_HoldRepeat_TurboOn[Target "_" Hold]:=1
While GetKeyState(Hold,"P") {
Send "{Blind}{" Target " down}"
Sleep 10
Send "{Blind}{" Target " up}"
Sleep 10
}
_HoldRepeat_TurboOn[Target "_" Hold]:=0
}
}