Browse Source

add parameter for whether send blind or not

master
Mar Alegre 3 years ago
parent
commit
720601068b
  1. 38
      lib/HoldRepeat.ahk
  2. 10
      src/Valheim.ahk

38
lib/HoldRepeat.ahk

@ -4,19 +4,28 @@
_HoldRepeat_TurboOn := Map()
Hold(Primary, Secondary:=[],Tertiary:=[]) {
Send "{Blind}{" Primary " down}"
SetTimer HoldLoop.Bind(Primary,Secondary,Tertiary), 50
_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) {
HoldLoop(Primary, Secondary, Tertiary,Prefix) {
if GetKeyState(Primary,"P") {
SetTimer , 0
return
}
for index,key in Secondary {
if GetKeyState(key,"P") {
Send "{Blind}{" Primary " up}"
Send Prefix "{" Primary " up}"
SetTimer , 0
return
}
@ -29,14 +38,15 @@ HoldLoop(Primary, Secondary, Tertiary) {
}
}
if (!keyHeld) {
Send "{Blind}{" Primary " up}"
Send Prefix "{" Primary " up}"
SetTimer , 0
return
}
}
Repeat(Primary, Secondary) {
Send "{Blind}{" Primary " up}"
Repeat(Primary, Secondary,SendBlind:=true) {
Prefix := _GetPrefix(SendBlind)
Send Prefix "{" Primary " up}"
Sleep 100
RepeatVar := 0
Loop {
@ -49,10 +59,10 @@ Repeat(Primary, Secondary) {
}
}
if (RepeatVar == 1) {
Send "{Blind}{" Primary " down}"
Send Prefix "{" Primary " down}"
RepeatVar := 0
} else {
Send "{Blind}{" Primary " down}"
Send Prefix "{" Primary " down}"
RepeatVar := 1
}
Sleep 100
@ -60,12 +70,12 @@ Repeat(Primary, Secondary) {
}
; Sets key to hold if single tap, or repeat if double tap
HoldOrRepeat(Primary, Secondary) {
Send "{Blind}{" Primary " down}"
HoldOrRepeat(Primary, Secondary,SendBlind:=True) {
Send _GetPrefix(SendBlind) "{" Primary " down}"
if KeyWait(Primary, "D T0.2") {
Repeat(Primary,Secondary)
Repeat(Primary,Secondary,SendBlind)
} else {
Hold(Primary,Secondary)
Hold(Primary,Secondary,,SendBlind)
}
}

10
src/Valheim.ahk

@ -16,12 +16,12 @@ WrapperWindow:="Valheim"
;
; Hold E
*#e UP::Hold("e",["LButton", "RButton","q","r"])
*#e UP::Hold("e",["LButton", "RButton","q","r"],,false)
; Autorun
*#w UP::Hold("w",["s"])
*#Shift UP::Hold("Shift",["Ctrl"])
*#w UP::Hold("w",["s"],,false)
*#Shift UP::Hold("Shift",["Ctrl"],,false)
; Autoclick
*#LButton UP::HoldOrRepeat("LButton",["RButton","MButton"])
*#RButton UP::HoldOrRepeat("RButton",["LButton","MButton"])
*#LButton UP::HoldOrRepeat("LButton",["RButton","MButton"],false)
*#RButton UP::HoldOrRepeat("RButton",["LButton","MButton"],false)
Loading…
Cancel
Save