Hold Left button for rapid fire Left Button

Post gaming related scripts
suetlung
Posts: 1
Joined: 17 Aug 2023, 01:17

Hold Left button for rapid fire Left Button

Post by suetlung » 17 Aug 2023, 01:29

I made this to play light gun games. This is my version 1 script

Code: Select all

Activated := false
Rapid := false

MButton & RButton::{
	global Activated := !Activated
	if (Activated) {
		ToolTip "Activated", 100, 100
		SetTimer () => ToolTip(), -2000
	} else {
		ToolTip "Deactivated", 100, 100
		SetTimer () => ToolTip(), -2000
	}
}

~LButton::
{
	global Rapid:=true

	while GetKeyState("LButton","P") and Activated{
		Send "{LButton down}"
		Sleep 45
		Send "{LButton up}"
		Sleep 45
	}
}

It works, but not perfectly. Sometimes, the rapid fire loop loops itself even I release my left button.
After some googling, I found that 'Sleep' sometime may affect the GetKeyState making it cannot return the actual state.

Then, here is version 2

Code: Select all

Activated := false
Rapid := false

MButton & RButton::{
	global Activated := !Activated
	if (Activated) {
		ToolTip "Activated", 100, 100
		SetTimer () => ToolTip(), -2000
	} else {
		ToolTip "Deactivated", 100, 100
		SetTimer () => ToolTip(), -2000
	}
}

~LButton::
{
	if (Activated) {
		FireLButton
		SetTimer FireLButton, 90
	}
}

LButton Up::
{
	SetTimer FireLButton, 0
}

FireLButton() {
	Send "{LButton down}"
	SetTimer () => Send("{LButton up}"), 45
	

}
I removed ALL the Sleeps and replace them with SetTimer. I finished the whole Time Crisis 2 with this script without mal functioning.

For those who want to do the same thing, hope this may help


[Mod action: Moved topic to the Gaming section.]

Return to “Gaming”