Help fixing right click script

Ask gaming related questions (AHK v1.1 and older)
HardBread
Posts: 2
Joined: 20 Aug 2017, 22:29

Help fixing right click script

20 Aug 2017, 22:38

Code: Select all

#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.

#IfWinActive StarCraft II

; Blink macro
LButton::
if (CheckSC2Active("LButton")) {
	send q ; Set this line to your blink hotkey
	Send {LButton}
}
Return

; Need to be able to left click, since we re bound LButton
$MButton::
if (CheckSC2Active("MButton Down")) {
	Send {LButton Down}
}
Return

$MButton Up::
if (CheckSC2Active("MButton Up")) {
	Send {LButton Up}
}
Return

; Hold RMB for blink spam
RButton::
delay = 20 ; delay between clicks, modify as desired
While GetKeyState("RButton","P") {
	IfWinActive StarCraft II
	{
		Click Right
	}
	Sleep delay
}
Return


; ~~ FUNCTIONS ~~ 

; Returns 1 if SC2 is active, 0 otherwise
IsSC2Active() {
	IfWinActive StarCraft II
	{
		Return 1
	}
	Return 0
}

; Presses the given key if SC2 is not the active window
; Returns 1 if SC2 is active, 0 otherwise
CheckSC2Active(key) {
	if (!IsSC2Active()) {
		Send %key%
		Return 0
	}
	Return 1
}

Is there anything here that would cause the right button spam to continue even after right mouse button release?
Thanks in advance!

Mod edit: Added code tags.
User avatar
sporefreak
Posts: 21
Joined: 23 Dec 2015, 02:38

Re: Help fixing right click script

21 Aug 2017, 01:38

Not that I can see, seems to work fine for me.
I see a lot of checking to see if SCII is open, is there a reason for that? Might be easier to just have it not check and only run the script when it is open.
If you tab out between games then try having a suspend script hotkey

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: sofista and 156 guests