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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Bender
Posts: 2
Joined: 13 May 2024, 02:50

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

Post by Bender » 13 May 2024, 03:12

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.]
Rohwedder
Posts: 7719
Joined: 04 Jun 2014, 08:33
Location: Germany

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

Post by Rohwedder » 13 May 2024, 07:28

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
dp924
Posts: 19
Joined: 11 Feb 2021, 07:20

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

Post by dp924 » 13 May 2024, 08:03

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

}
Bender
Posts: 2
Joined: 13 May 2024, 02:50

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

Post by Bender » 13 May 2024, 17:25

the first code doesn't work, I tried to change the value, I thought it would help, but it didn't work.
Rohwedder
Posts: 7719
Joined: 04 Jun 2014, 08:33
Location: Germany

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

Post by Rohwedder » 13 May 2024, 23:45

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
Post Reply

Return to “Ask for Help (v1)”