Why does this code bug out?

Ask gaming related questions (AHK v1.1 and older)
Huzzaa
Posts: 1
Joined: 15 Aug 2018, 03:19

Why does this code bug out?

15 Jul 2019, 12:03

Hi,

Wanted to ask some help regarding a piece of code I've put together.
The problem is. Sometimes the code causes to fail to register a key down event after pressing space multiple times.
As in, physically you are holding the key down but it failed to properly do it's work.

I use it to prevent tapping the keyboard unnecessarily in a favourite game of mine.

Code: Select all

#MenuMaskKey vk00sc000
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
~$1::
	Loop {
		GetKeyState, state, 1, P
		if (state == "U")
			break
		GetKeyState, state1, ScrollLock, T
		if (state1 == "U")
			break
		else {
			Send, 1
			Sleep, 10
		}
	}
	

I have a bunch of keys coded this way, this is 1 of them, all of the others follow suite in the exact manner.

Scroll Lock acts as a toggle.


Anyone got ideas to make it better? Or more specifically why does it sometimes bug out.

A concrete example is, I press(in reality, I actually hold the key down), 1 then 2, then 3 and also strafe at the same, a, d and jump a couple of times and then at times, most often, 1 and 2 stop running when I hold them down as usual. They start working fine right after I essentially tap them, (UP followed by DOWN and hold). But it takes me out of the flow, which is annoying.

Any help would be greatly appreciated.

PS. The code for some odd reason really makes the cursor erratic. Jumpy and as if it had acceleration at times. (This problem can be exacerbated with coding MOUSE4 or MOUSE5 into the code, then it becomes really bad)
User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

Re: Why does this code bug out?

15 Jul 2019, 17:09

Sometimes when things are not blocked off correctly, scripts can get kinda wonky.

Do you have the same issue with this?
It seems to work fine if i use my CapsLock key, but my KB doesn't have a ScrollLock key so I can't test that.

Code: Select all

~$1::
{	Loop,
	{	GetKeyState, state, 1, P
		if (state == "U")
		{	break
		} Else,
		;GetKeyState, state1, CapsLock, T
		GetKeyState, state1, ScrollLock, T
		if (state1 == "U")
		{	break
		} else,
		{	Send, 1
			Sleep, 10
}	}	} Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Performance and 39 guests