Help with keys sticking

Ask gaming related questions (AHK v1.1 and older)
ppp4
Posts: 2
Joined: 13 Jun 2021, 08:36

Help with keys sticking

Post by ppp4 » 13 Jun 2021, 08:44

Hello. I make this macro for spam keys in games and save my fingers. Work perfect, but i have only one(BIG) problem: some times key sticking in keydown position. I try one million combinations but i cant make this script work 100% perfect. Help me plz.

Code: Select all

#MaxHotkeysPerInterval 10000
#MaxThreadsPerHotkey 1
#MaxThreads 1
#MaxThreadsBuffer On
#SingleInstance Force 
#KeyHistory 0
#UseHook On
Critical On
SendMode Input
SleepTime = -1
KeyUpTime = 50
MessageQueue = -1
SpamModeEnabled = 0
#if (SpamModeEnabled = 1) 
;------------------------------------
;1
$vk31::
 While GetKeyState("vk31","P")
  {
    Sleep %SleepTime%
    SendInput {vk31 Down}
    Sleep %KeyUpTime%
    SendInput {vk31 Up}
    Sleep %MessageQueue%   
  }
Return
;------------------------------------
;2
$vk32::
  While GetKeyState("vk32","P")
  {
    Sleep %SleepTime%
    SendInput {vk32 Down}
    Sleep %KeyUpTime%
    SendInput {vk32 Up}
    Sleep %MessageQueue%   
  }
Return

;------------------------------------
;3
$vk33::
  While GetKeyState("vk33","P")
  {
    Sleep %SleepTime%
    SendInput {vk33 Down}
    Sleep %KeyUpTime%
    SendInput {vk33 Up}
    Sleep %MessageQueue%   
  }
Return
;------------------------------------
#if

$F11::
  if (SpamModeEnabled = 1) 
  {
    SpamModeEnabled := 0
    SoundPlay, %A_WinDir%\Media\tada.wav
  }
  else
  {
    SpamModeEnabled := 1
    SoundPlay, %A_WinDir%\Media\ringout.wav
  }

Return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 26604
Joined: 09 Sep 2014, 18:38

Re: Help with keys sticking

Post by mikeyww » 13 Jun 2021, 09:55

Try two million! :)

Just kidding. One type of "stuck key" phenomenon relates to conflicting keyboard hooks in other programs. You could try closing every other program, including non-Windows tray icons (programs "residing" in the tray), and then retesting in Notepad as a start. The KeyHistory can show you what is happening with the keys.

Since your script does not work, I would start with a simpler test such as the following (with no other code).

Code: Select all

$vk31::
SetKeyDelay, 20, 20
While GetKeyState("vk31", "P")
 Send {vk31}x
Return
ppp4
Posts: 2
Joined: 13 Jun 2021, 08:36

Re: Help with keys sticking

Post by ppp4 » 13 Jun 2021, 17:33

Thanks you! Works perfect!
Post Reply

Return to “Gaming Help (v1)”