Loop gets stuck spaming q+click Topic is solved

Ask gaming related questions (AHK v1.1 and older)
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Loop gets stuck spaming q+click

15 Mar 2018, 07:36

Helgef wrote:Also, try

Code: Select all

FKey:
critical
if x=0
in the unlikely event that you are releasing the key on the if x = 0 line (and I guess your computer lags a little) then the up hotkey could interrupt the down hotkey, so the timer is turned on again when the up hotkey finishes :crazy: . I couldn't reproduce your problems, although, I didn't make much of an effort :P.

Cheers.

Edit: Btw, why are you setting all those, mostly useless, settings at the top of the script, I see this often, where does it come from?
Hello, thank you again for taking your time to help me. Same to evilC.
Will try with adding critical to my label like you explained.
Will reply in 30 minutes or 1 hour of testing all alternatives.

About the code:

Code: Select all

#NoEnv ;I don't need to use env variables
#MaxHotkeysPerInterval 99000000 ;link below this code
#HotkeyInterval 99000000 ;link below this code
#KeyHistory 0 ;I don't need the keyhistory
#InstallKeybdHook ;I tried installing the keyboard hook to see if it fixed the problem
SetStoreCapslockMode, Off ;I need to ignore the capslock
ListLines Off ;I don't need the listlines
Process, Priority, , A ;link below this code
SetBatchLines, -1 ;Because i need it to run as fast as possible
SetKeyDelay, -1, -1  ;because sometimes i like to write send instead of sendinput
SetDefaultMouseSpeed, 0  ;because i need it to be as fast as possible
SetMouseDelay, -1 ;because i need it to be as fast as possible
SetWinDelay, -1 ;because i need it to be as fast as possible
SetControlDelay, -1 ;because i need it to be as fast as possible
https://autohotkey.com/boards/viewtopic.php?f=6&t=6413

It's the same settings i use on most of my scripts, it's easier to copy paste this instead of checking what i need.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Loop gets stuck spaming q+click

15 Mar 2018, 12:05

After trying several times to get some information i found this:

Keyhistory:

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q       	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q    	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q               	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q                 	
51  010	i	d	0.00	q             	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q                  	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                 	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                 	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                 	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                  	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                    	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q               	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q                      	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q                    	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q   

;This is the last time it shows a h=hoot hotkey press of q. So i think that from now it is not checking the key?
                  	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
01  000	 	d	0.00	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
01  000	 	u	0.02	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
01  000	 	d	0.02	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
01  000	 	u	0.00	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
01  000	 	d	0.02	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
01  000	 	u	0.00	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
01  000	 	d	0.01	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
01  000	 	u	0.01	LButton        	 ; This is not me pressing LButton
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	s	u	0.00	q       ;This was me pressing Q again to stop the loop because it was stuck, notice how it doesn't detect any q down event.
The same thing happens every time my loop gets stuck.

This is normal loop:

Code: Select all

51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.02	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.01	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.01	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	i	d	0.02	q              	
51  010	i	u	0.00	q              	
51  010	h	d	0.00	q              	
51  010	i	d	0.00	q              	
51  010	i	u	0.00	q              	
51  010	s	u	0.00	q  
Differences i see:
1_ It stops showing the Hook Hotkey down event. (while stuck)
2_ It starts to show mouse clicks up events but i'm not sending any event. (Important: The script is doing clicks but are not shown on normal loop. Those are only shown while the loop is stuck).
3_ It doesn't show the physical Q key up event. (while stuck).

Any ideas on what is causing this or some information i'm missing?.
Btw, is there any way to write all this key history into a txt because right now the limit of 500 is too low to see what happens from start.

This was tested using this script: (in game and in desktop)

Code: Select all

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#InstallMouseHook
#InstallKeybdHook
#KeyHistory 500
SetStoreCapslockMode, Off
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SetWinDelay, -1
SetControlDelay, -1
key:="q"
Hotkey, $%key%, Fkey
return

#MaxThreadsPerHotkey 1
FKey:
Critical
StringTrimLeft thishotkey, a_thisHotkey, 1
while GetKeyState(ThisHotkey, "P") 
{
	Sendinput {%thisHotkey%}
	Delay(0.005)
	sendinput {Click}
	Delay(0.005)
}
sendinput {Click}
Delay(0.005)
return

Delay( D=0.001 ) { ; High Resolution Delay ( High CPU Usage ) by SKAN | CD: 13/Jun/2009
Static F ; www.autohotkey.com/forum/viewtopic.php?t=52083 | LM: 13/Jun/2009
Critical
F ? F : DllCall( "QueryPerformanceFrequency", Int64P,F )
DllCall( "QueryPerformanceCounter", Int64P,pTick ), cTick := pTick
While( ( (Tick:=(pTick-cTick)/F)) <D ) {
DllCall( "QueryPerformanceCounter", Int64P,pTick )
Sleep -1
}
Return Round( Tick,3 )
}
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Loop gets stuck spaming q+click

16 Mar 2018, 02:58

It's the same settings i use on most of my scripts, it's easier to copy paste this instead of checking what i need.
It is a mistake. Putting random code in the script has the following implications,
  • Might cause the problem.
  • You are less likely to get help because, 1) there is more code, 2) you show you didn't make the effort to reduce the code to help us help you.
  • People helping you are less likely to succeed since they need to consider a bunch of (at best) irrelevant code,.

I suggest you remove all irrelevant settings and try again. When you get stuck, does other hook hotkeys work? Try to add $1::msgbox .... If there is a problem with the hook, you might want to use a non-hook hotkey and simply do a toggle on/off routine.

Cheers.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Loop gets stuck spaming q+click

16 Mar 2018, 04:35

evilC wrote:SetBatchLines, -1, for a start, is not to be used lightly.
I'm using it because with SetBatchLines, 10 the script is too slow.
Helgef wrote:
It's the same settings i use on most of my scripts, it's easier to copy paste this instead of checking what i need.
It is a mistake. Putting random code in the script has the following implications,
  • Might cause the problem.
  • You are less likely to get help because, 1) there is more code, 2) you show you didn't make the effort to reduce the code to help us help you.
  • People helping you are less likely to succeed since they need to consider a bunch of (at best) irrelevant code,.

I suggest you remove all irrelevant settings and try again. When you get stuck, does other hook hotkeys work? Try to add $1::msgbox .... If there is a problem with the hook, you might want to use a non-hook hotkey and simply do a toggle on/off routine.

Cheers.
Hello, sorry i wrote it wrong. When i said that i copy pasted i mean that i checked all those settings and used the one i needed, then copy pasted this list of settings i need from one script to another and check what i need from it.
In this case i need all those settings or that's what i think based on what i read in the forum and the ahk docs.

I tried removing everything to make only that loop work and forget about the rest of the program. Even isolated this part of the code and made 1 ahk with this code:

Code: Select all

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#InstallMouseHook
#InstallKeybdHook
#KeyHistory 500
SetStoreCapslockMode, Off
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SetWinDelay, -1
SetControlDelay, -1

key:="q"
Hotkey, $%key%, Fkey
return

#MaxThreadsPerHotkey 1
FKey:
Critical
StringTrimLeft thishotkey, a_thisHotkey, 1
while GetKeyState(ThisHotkey, "P") 
{
	Sendinput {%thisHotkey%}
	Delay(0.005)
	sendinput {Click}
	Delay(0.005)
}
sendinput {Click}
Delay(0.005)
return

1::msgbox asdasd ;Added this to try.

Delay( D=0.001 ) { ; High Resolution Delay ( High CPU Usage ) by SKAN | CD: 13/Jun/2009
Static F ; www.autohotkey.com/forum/viewtopic.php?t=52083 | LM: 13/Jun/2009
Critical
F ? F : DllCall( "QueryPerformanceFrequency", Int64P,F )
DllCall( "QueryPerformanceCounter", Int64P,pTick ), cTick := pTick
While( ( (Tick:=(pTick-cTick)/F)) <D ) {
DllCall( "QueryPerformanceCounter", Int64P,pTick )
Sleep -1
}
Return Round( Tick,3 )
}
I will try removing all settings and will reply again. Also will try what you said, if other keys work.

I don't use code that i don't understand, that's why before using those settings i read the docs and checked if i needed them.
Also did tests myself with:

Code: Select all

QPC( R := 0 ) {    ; By SKAN,  http://goo.gl/nf7O4G,  CD:01/Sep/2014 | MD:01/Sep/2014
  Static P := 0,  F := 0,     Q := DllCall( "QueryPerformanceFrequency", "Int64P",F )
Return ! DllCall( "QueryPerformanceCounter","Int64P",Q ) + ( R ? (P:=Q)/F : (Q-P)/F ) 
}
From this post: https://autohotkey.com/boards/viewtopic.php?t=4437
To see if the change is needed or not (when talking about speed improvements).
About the other settings: I had to add some for testing, and some for the script to work like i want.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Loop gets stuck spaming q+click

16 Mar 2018, 04:48

Tried with this settings:

Code: Select all

;#NoEnv
#MaxHotkeysPerInterval 99000000 ;Needed because if complains about the hotkeysperinterval
;#HotkeyInterval 99000000
#InstallMouseHook
#InstallKeybdHook
#KeyHistory 500
SetStoreCapslockMode, Off ;Used because i don't want my keyboard to go crazy if i have caps lock on. Also capslock doesn't matter in this game-
;ListLines Off
;Process, Priority, , A
;SetBatchLines, -1
;SetKeyDelay, -1, -1
;SetDefaultMouseSpeed, 0
;SetMouseDelay, -1
;SetWinDelay, -1
;SetControlDelay, -1
Same problem, it gets stuck.

About this:

1::msgbox, asd it doesn't work while stuck but the game recognizes if i press the "1" key while it is stuck looping the q+click. So it's only the script not detecting the key.
@edit: I forgot to add that if i do this:
1_hold down q and release until it gets stuck
2_While stuck press key "1".
3_press q again to break the loop.

It shows the msgbox after it broke the loop.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Loop gets stuck spaming q+click  Topic is solved

16 Mar 2018, 13:51

1::msgbox, asd it doesn't work while stuck
That is expected in the loop, since you have used critical. Please note that I meant for you to try $1::.

Code: Select all

#MaxHotkeysPerInterval 99000000 ;Needed because if complains about the hotkeysperinterval
Do you actually get the error if you remove this line?

Anyways, I think you might release the key during the sendInput {%thisHotkey%} line, and, if you have no other scripts running which uses a keyboard hook, sendinput is not reverting to sendevent, in which case ahk temporarily disables the hook during the call to the OS function sendinput(). Consequently, neither getkeystate(key,"p") nor up-hotkeys works while this line is executed. So you can test using sendevent with setkeydelay -1,-1 instead. And if you do not mind, please also try to run another script like this,

Code: Select all

#installkeybdhook
while still keeping sendInput in the q-click script.

Cheers.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Loop gets stuck spaming q+click

16 Mar 2018, 17:07

Helgef wrote:
1::msgbox, asd it doesn't work while stuck
That is expected in the loop, since you have used critical. Please note that I meant for you to try $1::.
Yes sry, i used $1:: wrote it wrong here.
Helgef wrote:

Code: Select all

#MaxHotkeysPerInterval 99000000 ;Needed because if complains about the hotkeysperinterval
Do you actually get the error if you remove this line?
I will try, the problem is that if i release the key the msgbox pops up so testing takes more time.
Helgef wrote: Anyways, I think you might release the key during the sendInput {%thisHotkey%} line, and, if you have no other scripts running which uses a keyboard hook, sendinput is not reverting to sendevent, in which case ahk temporarily disables the hook during the call to the OS function sendinput(). Consequently, neither getkeystate(key,"p") nor up-hotkeys works while this line is executed. So you can test using sendevent with setkeydelay -1,-1 instead. And if you do not mind, please also try to run another script like this,

Code: Select all

#installkeybdhook
while still keeping sendInput in the q-click script.

Cheers.
So, first i will try to run the code with sendinput.
And run another script with only this line #installkeybdhook.
Both as administrator.

Then i will try this:
sendevent and setkeydelay -1, -1.

And i will reply back with the results, thank you for helping me.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Loop gets stuck spaming q+click

17 Mar 2018, 16:40

So after 3 hours of running the script and testing i can say that:

Running another script with only this line #installkeybdhook fixes the problem. You were 100% correct from the first post, for some reason the keyboard hook gots uninstalled. But keeping that script running on background fixes the problem.

Also seems like using:
SendEvent instead of SendInput (with Setkeydelay, -1, -1
Works too, (still testing, will reply once again after i test it for 1 or 2 hours more).

Thank you guys for helping me with this, i've been having this problem since 2016 and couldn't solve it by myself.
Last edited by kyuuuri on 18 Mar 2018, 13:04, edited 1 time in total.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Loop gets stuck spaming q+click

18 Mar 2018, 10:56

That is good, and thank you for your thorough testing :thumbup:. Note, the second script with #installkeybdhook was meant only as a weak verification of my theories of the problem. The better option would be to use sendevent with setkeydelay. When you have another script with a keyboard hook running, the effect is basically that all your sendinput becomes sendevent with setKeyDelay -1, 0. Having a running script with a keyboard hook which does nothing else is just wasteful. And you might still want to use sendinput for other uses in your script, eg, for hotstrings.

@evilC, this is another problem with SendMode Input ; recommended for ... :think:.

Cheers.
Litaken
Posts: 9
Joined: 10 May 2021, 10:34

Re: Loop gets stuck spaming q+click

17 Aug 2021, 12:09

I got tired of not having one, so created a full solution to autofire, that doesn't get stuck and doesn't spam unwantedly (the SetTimer based autofire wasn't blocking, so it sent way more clicks that it should have), hope it helps

Code: Select all

;you cant have "return" before these functions

locks := []
RunLocked(key, lockFunc){
  global locks
  if (locks[key] != "lock") {
    locks[key] := "lock"
    lockFunc.call
  }
}

UnlockRun(key, unlockFunc){
  global locks
  locks[key] := "unlock"
  unlockFunc.call
}

; The "while GetKeyState" based autofire is unsafe and gets stuck a lot of the time. This doesn't. Presses key and re-calls itself asynchronously after a delay until keyheld is released
; Suggested not to use in itself as it will not block the same key to be pressed resulting in spaaaaaaaammy keys
AutoFireHotkey(key, keyheld, delay) {
  if GetKeyState("" keyheld, "P") {
    send {Blind}{%key%}
	sleep delay
	
    bind := Func("AutoFireHotkey").bind(key,keyheld,delay)
    SetTimer % bind, -1
  } else {
    ;send {Blind}END ; DEBUG this should run only once per keypress
  }
}

; We bind key that blocks recalling func of func until key has been released. This is the workaround to limit one key to one cycle of repetition
BindLocking(key, lockFunc, unlockFunc) {
  downFunc := Func("RunLocked").bind(key, lockFunc)
  Hotkey, % key, % downFunc, On

  upFunc := Func("UnlockRun").bind(key, unlockFunc)
  Hotkey, % key " Up", % upFunc, On
}

; actual bind that will spam 4 every 1000 ms until it's released
BindLocking("$F5", Func("AutoFireHotkey").bind(4,"F5",1000), null)

; you can do it like this as well
$F4::
  BindLocking("$F4", Func("AutoFireHotkey").bind(4,"F4",1000), null)
return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 59 guests