Page 1 of 1

help with a script for moving in a circle when pressing "x"  Topic is solved

Posted: 13 May 2024, 03:12
by Bender
I need a script that, when holding down "x", presses the key combination with a delay of 2 ms "w wd d ds s sa a aw" and so on in a circle until the "x" button is released. Thank you


[Mod edit: Removed empty codebox.]

Re: help with a script for moving in a circle when pressing "x"

Posted: 13 May 2024, 07:28
by Rohwedder
Hallo,
try:

Code: Select all

x::
N:=0, Keys:=["w Down","a Up","d Down"
,"w Up","s Down","d Up","a Down","s Up"]
While, GetKeyState("x","P")
	SendInput,% "{" Keys[++N:=Mod(N, 8)] "}"
Send, {a Up}{w Up}{d Up}{s Up}
Return

Re: help with a script for moving in a circle when pressing "x"

Posted: 13 May 2024, 08:03
by dp924

Code: Select all

x::
sendmove("w,wd,d,ds,s,sa,a,aw")
return


sendmove(Var)
{
	loop, Parse, Var, `,
	{
		send, % A_LoopField
		Sleep, 50
		if !GetKeyState("x", "P")
			break
	}
	return

}

Re: help with a script for moving in a circle when pressing "x"

Posted: 13 May 2024, 17:25
by Bender
the first code doesn't work, I tried to change the value, I thought it would help, but it didn't work.

Re: help with a script for moving in a circle when pressing "x"

Posted: 13 May 2024, 23:45
by Rohwedder
Perhaps the speed needs to be reduced? Try:

Code: Select all

x::
N:=0, Keys:=["w Down","a Up","d Down"
,"w Up","s Down","d Up","a Down","s Up"]
While, GetKeyState("x","P") {
	SendEvent,% "{" Keys[++N:=Mod(N, 8)] "}"
	Sleep, 50
}
SendEvent, {a Up}{w Up}{d Up}{s Up}
Return