AutoClicker function that passes key to be clicked Topic is solved

Ask gaming related questions (AHK v1.1 and older)
ProjectRay12
Posts: 1
Joined: 24 Feb 2018, 16:13

AutoClicker function that passes key to be clicked

24 Feb 2018, 17:04

I have this script I'm working on to allow me to repeatedly press a key as long as it is held down when a boolean is toggled to true. The issue is, it doesn't. As it stands, I know that repeat is receiving "LButton" and {Click} correctly, but the while loop always seems to fail i.e. no clicks. The goal I'm shooting for, is when state is true, as long as you hold down the mouse button, it will repeatedly click, but will stop as soon as you let go of the mouse button. Code below:

Code: Select all

global state := false

hotkey, CapsLock, toggleState
hotkey, ~*LButton, rep1

toggleState()
{
  if (state)
    state := false
  else
    state := true
}

repeat(key, act)
{
  bState := getKeyState(%key%, "P")
  while (state AND bState)
  {
    sendInput %act%
    Sleep 10
    bState := getKeyState(key, "P")
  }
}

rep1:
  repeat("LButton", "{Click}")
return
Anyone thing they can help me out?

Edit: Thanks for the answer! I guess I just didn't quite understand parameters and how variables work with these types.
Last edited by ProjectRay12 on 24 Feb 2018, 18:12, edited 1 time in total.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: AutoClicker function that passes key to be clicked  Topic is solved

24 Feb 2018, 18:04

Code: Select all

bState := getKeyState(%key%, "P")
Should be:

Code: Select all

bState := getKeyState(key, "P")

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 58 guests