AHK Script for multiple clicks + assignments

Ask gaming related questions (AHK v1.1 and older)
nibsrs
Posts: 5
Joined: 01 Dec 2021, 11:50

AHK Script for multiple clicks + assignments

01 Dec 2021, 11:52

Hey guys, I am completely newbie with AHK and started just yesterday. I want to create a script to make my lmb clicks 4 times in a row. Until now everything works fine with my script but it's really simple and I want to improve. What I want is a way to assign a single left click to my RMB, so I can use LMB to left click 4 times and RMB to left click only 1. Is it possible to do with AHK?
Also, any way I can do a script so when I press LMB it will loop until I release the LMB?

Here's my script:

Code: Select all

home::Suspend
Lbutton::
loop, 4
{
Send {Lbutton}
sleep 12
}
return
Thank you for the help.
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: AHK Script for multiple clicks + assignments

01 Dec 2021, 12:29

Code: Select all

RButton::LButton
LButton::
While GetKeyState(A_ThisHotkey, "P")
 Click
Return
nibsrs
Posts: 5
Joined: 01 Dec 2021, 11:50

Re: AHK Script for multiple clicks + assignments

01 Dec 2021, 12:46

mikeyww wrote:
01 Dec 2021, 12:29

Code: Select all

RButton::LButton
LButton::
While GetKeyState(A_ThisHotkey, "P")
 Click
Return
Hello, thanks for the code. The assignment question is solved.
But about your script, it works but I need to press LMB again to make it stops. What I want is something that while I have the lmb button pressed, it'll loop until I release the lmb.
nibsrs
Posts: 5
Joined: 01 Dec 2021, 11:50

Re: AHK Script for multiple clicks + assignments

01 Dec 2021, 12:47

@mikeyww

Hello, thanks for the code. The assignment question is solved.
But about your script, it works but I need to press LMB again to make it stops. What I want is something that while I have the lmb button pressed, it'll loop until I release the lmb.
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: AHK Script for multiple clicks + assignments

01 Dec 2021, 12:58

That is what the script does. Test it in Notepad. The subroutine is not a toggle. Save and reload; exit other scripts before running this. Run this script with no other code included.
nibsrs
Posts: 5
Joined: 01 Dec 2021, 11:50

Re: AHK Script for multiple clicks + assignments

01 Dec 2021, 13:12

@mikeyww
Oh okay, but I think that sometimes it goes crazy and clicks infinitely. Any way to fix that?
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: AHK Script for multiple clicks + assignments

01 Dec 2021, 13:22

You can add a sleep.

Code: Select all

RButton::LButton
LButton::
While GetKeyState(A_ThisHotkey, "P") {
 Click
 Sleep, 25
}
Return
nibsrs
Posts: 5
Joined: 01 Dec 2021, 11:50

Re: AHK Script for multiple clicks + assignments

01 Dec 2021, 13:32

@mikeyww
Thank you! Does this P means "pressed"? If yes I assume R is "released" right?

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 96 guests