Script for hold down a key and rapid key press(random) with extra mouse button

Post gaming related scripts
souvy
Posts: 1
Joined: 09 Dec 2021, 07:20

Script for hold down a key and rapid key press(random) with extra mouse button

10 Dec 2021, 15:15

Hi All,I was searching for a rapid key script.
Couldn't find my specific use case for genshin impact. (You can modify it for other game also)
XButton1 & XButton2 :
Spoiler
Use case:
1. You can walk with pressings XButton2 it will keep walking. (Added random shift key press because genshin have this sprint dash action) (If you want shift to be pressed all time replace SendTheKey()
with SendInput, {Shift down} and in else put SendInput, {Shift up}

2. For XButton1 it's random interval space autofire.

*If you don't want the random delay part, reply here will upload a script without it.
*you can relpace XButton2 if you want to trigger the functions with any other key.
List of hotkeys: https://www.autohotkey.com/docs/Hotkeys.htm

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
RepeatKey := 0
RepeatKey1 := 0
*XButton2::
	RepeatKey := !RepeatKey
	If RepeatKey {
		SendTheKey()
		SendInput, {w down} ;change 'w' with any other key that you want 
		
	}
	If !RepeatKey {
		SetTimer, SendTheKey, Off
		SendInput, {w up} ;change 'w' with any other key that you want 
	}
	Return

SendTheKey() {
	SendInput {Shift}
	Random, r, 55, 123
	SetTimer, SendTheKey, -%r%
	Return
}

*XButton1::
	RepeatKey1 := !RepeatKey1
	If RepeatKey1
		SendTheSpace()
	If !RepeatKey1
		SetTimer, SendTheSpace, Off
	Return

SendTheSpace() {
	SendInput {Space}
	Random, r, 515, 727
	SetTimer, SendTheSpace, -%r%
	Return
}
PS: If anyone want a script which will press down any key after pressing down a specific hotkey or trigger here's a script link:
viewtopic.php?t=55296

Other guide for different implementation of auto fire:
https://www.autohotkey.com/board/topic/64576-the-definitive-autofire-thread/

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 17 guests