Browse Source

update prelude, wrapper, holdrepeat, drg for v2

fix turbo sometimes not turning off bug

add turbo jump to drg
master
Mar Alegre 3 years ago
parent
commit
c614cc4e94
  1. 60
      lib/HoldRepeat.ahk
  2. 18
      lib/Prelude.ahk
  3. 7
      lib/Wrapper.ahk
  4. 54
      src/Deep Rock Galactic.ahk

60
lib/HoldRepeat.ahk

@ -2,32 +2,41 @@
; Functions for holding and repeating keys ; Functions for holding and repeating keys
; ;
_TurboOn := [] _TurboOn := Map()
Hold(Primary, Secondary) { Hold(Primary, Secondary:=[],Tertiary:=[]) {
Send, {Blind}{%Primary% down} Send "{Blind}{" Primary " down}"
if ( Secondary.Length() != 0 ) { SetTimer HoldLoop.Bind(Primary,Secondary,Tertiary), 50
ThisLoop := Func("HoldLoop").bind(Primary,Secondary)
SetTimer, %ThisLoop%, 50
}
} }
HoldLoop(Primary, Secondary) { HoldLoop(Primary, Secondary, Tertiary) {
if GetKeyState(Primary,"P") { if GetKeyState(Primary,"P") {
SetTimer, , Delete SetTimer , 0
return return
} }
for index,key in Secondary { for index,key in Secondary {
if GetKeyState(key,"P") { if GetKeyState(key,"P") {
Send, {Blind}{%Primary% up} Send "{Blind}{" Primary " up}"
SetTimer, , Delete SetTimer , 0
return return
} }
} }
keyHeld:=0
for index,key in Tertiary {
if GetKeyState(key,"P") {
keyHeld:=1
break
}
}
if (!keyHeld) {
Send "{Blind}{" Primary " up}"
SetTimer , 0
return
}
} }
Repeat(Primary, Secondary) { Repeat(Primary, Secondary) {
Send, {Blind}{%Primary% up} Send "{Blind}{" Primary " up}"
Sleep 100 Sleep 100
RepeatVar := 0 RepeatVar := 0
Loop { Loop {
@ -40,10 +49,10 @@ Repeat(Primary, Secondary) {
} }
} }
if (RepeatVar == 1) { if (RepeatVar == 1) {
Send, {Blind}{%Primary% down} Send "{Blind}{" Primary " down}"
RepeatVar := 0 RepeatVar := 0
} else { } else {
Send, {Blind}{%Primary% up} Send "{Blind}{" Primary " down}"
RepeatVar := 1 RepeatVar := 1
} }
Sleep 100 Sleep 100
@ -52,9 +61,8 @@ Repeat(Primary, Secondary) {
; Sets key to hold if single tap, or repeat if double tap ; Sets key to hold if single tap, or repeat if double tap
HoldOrRepeat(Primary, Secondary) { HoldOrRepeat(Primary, Secondary) {
Send, {Blind}{%Primary% down} Send "{Blind}{" Primary " down}"
KeyWait, %Primary%, D, T0.2 if (KeyWait Primary, "D T0.2") {
if (ErrorLevel = 0) {
Repeat(Primary,Secondary) Repeat(Primary,Secondary)
} else { } else {
Hold(Primary,Secondary) Hold(Primary,Secondary)
@ -62,18 +70,22 @@ HoldOrRepeat(Primary, Secondary) {
} }
; Press Target button extremely rapidly while Hold button is held down ; Press Target button extremely rapidly while Hold button is held down
Turbo(Target,Hold) { TurboOn(Target,Hold:=Target) {
global _TurboOn global _TurboOn
If (_TurboOn["%Target%_%Hold%"]) { If (_TurboOn.Has(Target "_" Hold) and _TurboOn[Target "_" Hold]) {
return return
} else { } else {
_TurboOn["%Target%_%Hold%"]:=1 _TurboOn[Target "_" Hold]:=1
While GetKeyState(Hold,"P") { While _TurboOn[Target "_" Hold] {
Send, {Blind}{%Target% down} Send "{Blind}{" Target " down}"
Sleep 10 Sleep 10
Send, {Blind}{%Target% up} Send "{Blind}{" Target " up}"
Sleep 10 Sleep 10
} }
_TurboOn["%Target%_%Hold%"]:=0
} }
}
TurboOff(Target,Hold:=Target) {
global _TurboOn
_TurboOn[Target "_" Hold]:=0
} }

18
lib/Prelude.ahk

@ -5,21 +5,19 @@
; Set default location and name convention for compiled scripts to use ; Set default location and name convention for compiled scripts to use
;@Ahk2Exe-ExeName %A_MyDocuments%\AutoHotkey\bin\%A_ScriptName% ;@Ahk2Exe-ExeName %A_MyDocuments%\AutoHotkey\bin\%A_ScriptName%
; Install hooks to make sure script can get physical state of keys instead of logical state. ; Require AutoHotKey v2
#InstallKeybdHook #Requires AutoHotkey v2.0
#InstallMouseHook
#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.
; Install hooks to make sure script can get physical state of keys instead of logical state.
InstallKeybdHook
InstallMouseHook
; All hotkeys are implemented through keyboard hook to avoid script activating itself. ; All hotkeys are implemented through keyboard hook to avoid script activating itself.
#UseHook #UseHook
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
; MenuMaskKey is set to a virtual key that is defined by Windows as doing nothing ; MenuMaskKey is set to a virtual key that is defined by Windows as doing nothing
#MenuMaskKey vkFF A_MenuMaskKey := "vkFF"
; If script is already running, just override it with the new version instead of asking ; If script is already running, just override it with the new version instead of asking
#SingleInstance force #SingleInstance force

7
lib/Wrapper.ahk

@ -8,10 +8,9 @@ CheckWinExist(Window) {
} }
} }
Run %WrapperPath% Run WrapperPath
SetTitleMatchMode 3 SetTitleMatchMode 3
WinWait %WrapperWindow%,,600 WinWait WrapperWindow,,600
; Check if window exists once per second ; Check if window exists once per second
WrapperFunc := Func("CheckWinExist").bind(WrapperWindow) SetTimer CheckWinExist.Bind(WrapperWindow), 1000
SetTimer, %WrapperFunc%, 1000

54
src/Deep Rock Galactic.ahk

@ -1,18 +1,15 @@
; Script can be directly run by or compiled into an .exe by the open-source software AutoHotkey ;
; https://www.autohotkey.com
;
; Front Matter ; Front Matter
; ;
; Include relevant libraries ; Include relevant libraries
#Include ../lib/Prelude.ahk #Include "../lib/Prelude.ahk"
#Include ../lib/HoldRepeat.ahk #Include "../lib/HoldRepeat.ahk"
; Make this a wrapper script ; Make this a wrapper script
WrapperPath:="steam://rungameid/548430" WrapperPath:="steam://rungameid/548430"
WrapperWindow:="Deep Rock Galactic " WrapperWindow:="Deep Rock Galactic "
#Include ../lib/Wrapper.ahk #Include "../lib/Wrapper.ahk"
; Initialize variables ; Initialize variables
FullAutoEnabled := [0,0,0,0] FullAutoEnabled := [0,0,0,0]
@ -21,34 +18,43 @@ EquipState := 1
ToggleFullAuto(Index) { ToggleFullAuto(Index) {
global FullAutoEnabled global FullAutoEnabled
FullAutoEnabled[Index] := !FullAutoEnabled[Index] FullAutoEnabled[Index] := !FullAutoEnabled[Index]
EnabledDisabled := % (FullAutoEnabled[Index] ? "enabled" : "disabled") EnabledDisabled := (FullAutoEnabled[Index] ? "enabled" : "disabled")
ToolTip, Full Auto %EnabledDisabled% for %Index%, % A_ScreenWidth // 2, % A_ScreenHeight // 2 ToolTip "Full Auto " EnabledDisabled " for " Index, A_ScreenWidth // 2, A_ScreenHeight // 2
SetTimer, RemoveTooltip, -1000 SetTimer RemoveTooltip, -1000
} }
RemoveTooltip: RemoveTooltip() {
ToolTip ToolTip
return }
; ;
; Hotkeys ; Hotkeys
; ;
; Keep track of what is equipped ; Keep track of what is equipped
~*1:: EquipState := 1 ~*1:: global EquipState:=1
~*2:: EquipState := 2 ~*2:: global EquipState:=2
~*3:: EquipState := 3 ~*3:: global EquipState:=3
~*4:: EquipState := 4 ~*4:: global EquipState:=4
; FN toggles full auto for weapon N ; FN toggles full auto for weapon N
~*F1::ToggleFullAuto(1) *F1::ToggleFullAuto(1)
~*F2::ToggleFullAuto(2) *F2::ToggleFullAuto(2)
~*F3::ToggleFullAuto(3) *F3::ToggleFullAuto(3)
~*F4::ToggleFullAuto(4) *F4::ToggleFullAuto(4)
; Alt + E holds E ; Alt + E holds E
*!e UP::Hold("e",["e","w","a","s","d","Space","LButton","RButton"]) *!e UP::Hold("e",["w","a","s","d","Space","LButton","RButton"])
; Press shift to sprint, only toggles on
*LShift::Send "{Blind}{LShift down}"
*LShift UP::Hold("LShift",,["w"])
; Hold space rapidly jumps
*Space::TurboOn("Space")
*Space UP::TurboOff("Space")
; Do full auto when caps lock is on for enabled weapons ; Do full auto when caps lock is on for enabled weapons
#If (GetKeyState("CapsLock","T") and FullAutoEnabled[EquipState]) #HotIf (GetKeyState("CapsLock","T") and FullAutoEnabled[EquipState])
*LButton::Turbo("LButton","LButton") *LButton::TurboOn("LButton")
*LButton UP::TurboOff("LButton")
Loading…
Cancel
Save