Need help with script. Info inside. Topic is solved

Ask gaming related questions (AHK v1.1 and older)
emsurvive

Need help with script. Info inside.

21 Dec 2015, 15:34

Hello guys. First time posting here.

So I have a script that allows me to jump repeatedly. But when I press W (to run) and Shift (To sprint) The Space bar doesnt work.

Here is the script

#usehook ;*1

hotkey, space, spam ;*2
return

spam: ;*3
{
while getkeystate(a_thishotkey, "p") ;*4
{
sleep, 200 ;*5
sendinput, {%a_thishotkey%} ;*6
}
}
return

end::exitapp ;*7

/*
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Need help with script. Info inside.

21 Dec 2015, 16:01

Try changing hotkey, space, spam ;*2 to hotkey, *space, spam ;*2.
emsurvive

Re: Need help with script. Info inside.  Topic is solved

21 Dec 2015, 16:13

Shadowpheonix wrote:Try changing hotkey, space, spam ;*2 to hotkey, *space, spam ;*2.
Space doesnt work at all now.
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Need help with script. Info inside.

21 Dec 2015, 16:16

Odd, as it worked when I tested it in Notepad.

Edit:
My mistake. When I tested, I used a version of the script that did not use A_ThisHotkey. I tried it with A_ThisHotkey and it does indeed fail for me as well.

The options I see are to either...
A) Replace all references to A_ThisHotkey with Space, which may cause problems if you use that Spam section for other hotkeys also.
B) Create additional hotkeys to cover Shift+Space, Alt+Space, Ctrl+Space, and any other combinations you may use.
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Need help with script. Info inside.

22 Dec 2015, 00:26

Another alternative is to strip the leading * from A_ThisHotkey. i.e. using *Space causes A_ThisHotkey to contain *Space (not Space, without the *) and since no such key exists GetKeyState is always returning false. Even if you forced the GetKeyState to be Space, the sendinput would also not send a simple space but possibly a * and Space if anything at all. Personally I'd do something like this:

Code: Select all

spam: ;*3
{
	Button := LTrim(A_ThisHotkey, "~*$<>^!#+")
	while getkeystate(Button, "p") ;*4
	{
		sleep, 200 ;*5
		sendinput, {%Button%} ;*6
	}
}
return
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Need help with script. Info inside.

22 Dec 2015, 09:30

When I said "Replace all references to A_ThisHotkey with Space, which may cause problems if you use that Spam section for other hotkeys also", it was intended to include the reference on the SendInput line specifically to avoid that issue. However, your solution presents a 3rd option that I think is better than either of the ones I suggested.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 89 guests