simple loop gets stuck

Ask gaming related questions (AHK v1.1 and older)
Haligator
Posts: 4
Joined: 31 May 2022, 12:20

simple loop gets stuck

Post by Haligator » 11 Jul 2022, 12:30

Code: Select all

; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


SendMode Input
SetWorkingDir %A_ScriptDir%

LCtrl & space:: ;Bunny Hop Tap Strafe
	Loop
	{
	GetKeyState,state,space,P
	If state = U
	break

 	Send,{space}
	Send,{WheelUp}
	Sleep,10
	GetKeyState, state, space, P
				if state = U ;
				break
	}
	return
trying to tap strafe/ bunny hop in apex legends but sometimes when i release space the loop gets stuck till i press space again. what did i wrong?

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: simple loop gets stuck

Post by mikeyww » 11 Jul 2022, 18:18

While you test, you can slow down the loop by adding some sleep, and display the values of your key states. You can check the KeyHistory to see what is happening with the keys, too.

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: simple loop gets stuck

Post by boiler » 12 Jul 2022, 05:22

This doesn’t address the reason it gets stuck, but I’m not seeing a reason to put the check at the beginning and end of the loop. You are effectively just checking it twice in a row (the one at the end followed by the one at the beginning) with no time in between checks.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: simple loop gets stuck

Post by mikeyww » 12 Jul 2022, 06:49

Good point.

The following seemed to work in Notepad.

Code: Select all

LCtrl & Space::
While GetKeyState("Space", "P") {
 Send {Space}{WheelUp}
 Sleep, 15
}
Return

Haligator
Posts: 4
Joined: 31 May 2022, 12:20

Re: simple loop gets stuck

Post by Haligator » 12 Jul 2022, 12:34

thank you so much its working :)

Haligator
Posts: 4
Joined: 31 May 2022, 12:20

Re: simple loop gets stuck

Post by Haligator » 12 Jul 2022, 15:46

Haligator wrote:
12 Jul 2022, 12:34
thank you so much its working :)
oh no still gets stuck

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: simple loop gets stuck

Post by mikeyww » 12 Jul 2022, 16:45

Sorry I have no new recommendations for you.

shanshans
Posts: 27
Joined: 13 Dec 2015, 08:10

Re: simple loop gets stuck

Post by shanshans » 14 Jul 2022, 11:50

This is actually an old problem when you using "&"

Let's me show you the jamming issue with this key checking site so you can understand what happen
(I use it to debug, very cool tool)
https://www.iobit.com/en/keyboard-test.php

~1 & 2::3
press 1 > then press 2 , output 3 - no problem

But

press 1 > press and keep holding 2 > release 1 - stuck with 3

press 2 >press and keep holding 1 > release 2 - stuck with 2

They lose the key up function when the combination is not more (i guess XD)

My current solution is using ticket var. and #if to force them release the keys
or break them down key by key like this

2 up:: ;(may need to add 1 up , i don't know , but this is the idea)
send {2 up}
send {3 up}
return

earlbond84
Posts: 19
Joined: 16 Jul 2022, 09:26

Re: simple loop gets stuck

Post by earlbond84 » 19 Jul 2022, 09:41

Hi @shanshans

Try this...

viewtopic.php?f=18&t=106523

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: simple loop gets stuck

Post by boiler » 19 Jul 2022, 10:23

@earlbond84 - Please stop linking to your other thread in places where it doesn’t apply. I’ve already removed the instances of your external link spam including your attempt to work around it, and the spamming of your thread is also becoming a nuisance.

earlbond84
Posts: 19
Joined: 16 Jul 2022, 09:26

Re: simple loop gets stuck

Post by earlbond84 » 19 Jul 2022, 16:37

Hi @boiler

How can you tell that it doest apply.
When it can help many users since it has many examples.
Also the lack of documentation that is easy to understand
by the beginners is the main problem is here.
Dont compare admins & begginers level
Since their experience is already a gap.
If this forum has proper well document & easy to understand
documentation.
Most newbies wont ask anymore help.

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: simple loop gets stuck

Post by boiler » 19 Jul 2022, 17:06

@earlbond84 -- Whether it can help them or not, it has to be relative to the topic you're posting in. Your tutorial doesn't cover looping until a key is released. I might understand if you posted it only here, but you have posted it in several places very soon after you created it. It looks more like spam, especially since several of your posts already included actual spam.

Post Reply

Return to “Gaming Help (v1)”