2 buttons with one

Ask gaming related questions (AHK v1.1 and older)
simonebet
Posts: 8
Joined: 01 Feb 2024, 11:02

2 buttons with one

01 Feb 2024, 16:21

I need a script that does the following job:
if I hold down a key, for example the letter A, it automatically spams A and the left mouse button.
I need the letter a and the left mouse button to spam one after the other, and in loop.
when I release the button, it stops spamming
User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: 2 buttons with one

01 Feb 2024, 17:23

Code: Select all

#Requires AutoHotkey v1.1.33
$a::
While GetKeyState("a", "P")
 Send a{LButton}
Return
simonebet
Posts: 8
Joined: 01 Feb 2024, 11:02

Re: 2 buttons with one

01 Feb 2024, 18:56

How can i set delay btw A key and left click mouse? It must to be fast and in loop
User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: 2 buttons with one

01 Feb 2024, 21:50

Code: Select all

#Requires AutoHotkey v1.1.33

$a::
While GetKeyState("a", "P") {
 Send a
 Sleep 100
 Click
}
Return
simonebet
Posts: 8
Joined: 01 Feb 2024, 11:02

Re: 2 buttons with one

02 Feb 2024, 04:42

doesnt work. it doesnt hve left mnouse click after a
User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: 2 buttons with one

02 Feb 2024, 07:43

This version releases modifiers. Test in Notepad as a first step. Use only this script, with no additions and no changes. Close other scripts first.

Code: Select all

#Requires AutoHotkey v1.1.33

$a::
SetKeyDelay 25, 25
While GetKeyState("a", "P") {
 SendEvent a
 Sleep 100
 SendEvent {LButton}
}
Return
simonebet
Posts: 8
Joined: 01 Feb 2024, 11:02

Re: 2 buttons with one

02 Feb 2024, 16:42

why doesn't it work in some games?
User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: 2 buttons with one

02 Feb 2024, 17:27

If this script works in Notepad but not in your game, there could be various reasons. Some programs require longer key delays (which you can adjust), or a different Send mode. Some require an elevated script (which can be run). Some block scripting. The specific sleep might require adjustment. There could be additional or alternative reasons that are difficult to determine. You may need to experiment.
simonebet
Posts: 8
Joined: 01 Feb 2024, 11:02

Re: 2 buttons with one

06 Feb 2024, 13:41

mikeyww wrote:
02 Feb 2024, 17:27
If this script works in Notepad but not in your game, there could be various reasons. Some programs require longer key delays (which you can adjust), or a different Send mode. Some require an elevated script (which can be run). Some block scripting. The specific sleep might require adjustment. There could be additional or alternative reasons that are difficult to determine. You may need to experiment.
If instead I want it to always click the letter A when I hold down the A key?
User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: 2 buttons with one

06 Feb 2024, 13:47

You can delete the click or sending of LButton. The Send command sends whatever text you like. Have at it.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 30 guests