AutoHotkey sends keys out of order & keys not released issue

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Adovin
Posts: 9
Joined: 02 Feb 2018, 21:49

AutoHotkey sends keys out of order & keys not released issue

10 Feb 2018, 17:44

A script I'm using is supposed to press & hold these keys (W, D, S, A) for 500 milliseconds in that exact order. For example: it would hold W for 500 milliseconds, quickly release the key and then hold the next key for 500 milliseconds and so on. Though there is an issue, when I initially start the script it's almost as if it needs to warm up or something, it presses the keys in the wrong order (sometimes pressing a key twice) and only after a couple seconds does it fix itself and starts pressing the keys in the correct order with the 500 millisecond delay I wanted. Which was fine until I found out that this happens each time I exit and start the script or reload it, and also takes longer to fix itself if my delay is longer (let's say 2000 milliseconds instead of 500 milliseconds).

Here is an example video showing this issue:



Another problem (which I didn't show in the video) is that when I pause the script while a key is being held down for 500 milliseconds, that key stays held down. This only happens in games though. Didn't seem to do it on Notepad. Anyway, I just want to be able to press one hotkey to release all keys that are currently being held down and then pause the script.


EDIT: Forgot to include the script I'm using. My apologies, here it is:

Code: Select all

Pause
#NoEnv
#MaxHotkeysPerInterval 999999999999
#HotkeyInterval 999999999999
#KeyHistory 0
ListLines Off
Process, Priority, , H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input

SetTimer, PressKey, 0

PressKey:
		Send, {w Down}
		DllCall("Sleep","UInt",500)
		Send, {w Up}
		Send, {d Down}
		DllCall("Sleep","UInt",500)
		Send, {d Up}
		Send, {s Down}
		DllCall("Sleep","UInt",500)
		Send, {s Up}
		Send, {a Down}
		DllCall("Sleep","UInt",500)
		Send, {a Up}
return

~$F4::Pause
~$F5::ExitApp
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: [HELP] AutoHotkey sends keys out of order & keys not released issue

10 Feb 2018, 19:40

Why do you have a period of 0 for your SetTimer? Why even use SetTimer if you just want it to immediately repeat. Just put a loop around it.
User avatar
Adovin
Posts: 9
Joined: 02 Feb 2018, 21:49

Re: [HELP] AutoHotkey sends keys out of order & keys not released issue

10 Feb 2018, 22:06

That's irrelevant to the topic but I suppose I should change that lol
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: [HELP] AutoHotkey sends keys out of order & keys not released issue

10 Feb 2018, 22:51

I'm just saying, if you can't figure out why it's acting weird, I wouldn't put it in a SetTimer with a period of 0.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [HELP] AutoHotkey sends keys out of order & keys not released issue

11 Feb 2018, 06:45

I suggest you put a return after settimer. Why do you have Pause at the top of the script? Why do you (and many others) have all those irrelevant settings? Also see sleep.

Cheers.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 364 guests