Left click loop

Ask gaming related questions (AHK v1.1 and older)
KnightAckbar
Posts: 5
Joined: 29 Mar 2024, 17:43

Left click loop

30 Mar 2024, 01:04

Hello everyone, I need help with a left mouse click repeat script. I would like when I hold down the E key the left mouse click is sent in a loop until I release the E key. I tried to create this script, but in my code once launched the loop no longer stops whether E is pressed or not. If anyone can give me some research directions. Thanks

Code: Select all

e::
    {
    Toggle := !Toggle
    While, Toggle
        {
        Click down
        Sleep 1000
        Click up
        }
    }
return
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
gregster
Posts: 9036
Joined: 30 Sep 2013, 06:48

Re: Left click loop

30 Mar 2024, 01:38

Should we assume that this is an AHK v2 question because it has been posted in AHK v2 help? This looks much more like AHK v1 code.
We can move the topic, if it's a v1 question.
KnightAckbar
Posts: 5
Joined: 29 Mar 2024, 17:43

Re: Left click loop

30 Mar 2024, 10:57

Hello, I'm using version 2.0.12, but maybe my code is outdated. How can I know the version ?
gregster
Posts: 9036
Joined: 30 Sep 2013, 06:48

Re: Left click loop

30 Mar 2024, 11:18

There seems to be some confusion about the used version. Just try to run the code above with v2 (eg, if you add #Requires AutoHotkey v2.0 - and it will error out and never run.
If you are actually using the code above, you are running it with v1. Add msgbox %A_AHKversion% at the top to confirm.
KnightAckbar
Posts: 5
Joined: 29 Mar 2024, 17:43

Re: Left click loop

30 Mar 2024, 14:22

Indeed the command line #Requires AutoHotkey v2.0 generates an error "Error: This line does not contain a recognized action." But, the msgbox %A_AHKversion% command line works and gives me a window with 1.1.37.02 in it. Sorry for the inconvenience, I must be in the right section.
User avatar
boiler
Posts: 16996
Joined: 21 Dec 2014, 02:44

Re: Left click loop

30 Mar 2024, 15:14

KnightAckbar wrote: Indeed the command line #Requires AutoHotkey v2.0 generates an error "Error: This line does not contain a recognized action." But, the msgbox %A_AHKversion% command line works and gives me a window with 1.1.37.02 in it.
This is quite odd because that particular error message should only be produced by a version that is too old to recognize the #Requires directive (prior to v1.1.33). The message produced by v1.1.37.02 should say that the script requires a version that you don’t have installed.

KnightAckbar wrote: Sorry for the inconvenience, I must be in the right section.
Actually, you are not in the right section because you only have v1 installed and you posted in the v2 section. So do you want to continue using and getting help with v1, in which case we’ll move the thread to the v1 section, or do you want to install v2 and get help turning your code into a working v2 script?
KnightAckbar
Posts: 5
Joined: 29 Mar 2024, 17:43

Re: Left click loop

30 Mar 2024, 17:48

I prefer to stay on V1 for the moment, if you can move my thread to the V1 section. Thanks
Last edited by gregster on 30 Mar 2024, 18:34, edited 1 time in total.
Reason: Topic habs been moved to v1 help.
KnightAckbar
Posts: 5
Joined: 29 Mar 2024, 17:43

Re: Left click loop

31 Mar 2024, 04:58

Hello everyone, this works for me.

Code: Select all

$e::
            While GetKeyState("e","p"){ ; While it is held down
            MouseClick, Left
            Sleep 100
}      
return
The problem is solved for me.


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
User avatar
boiler
Posts: 16996
Joined: 21 Dec 2014, 02:44

Re: Left click loop

31 Mar 2024, 06:03

@KnightAckbar — Please use [code][/code] tags when posting code on the forum, as the moderators have been doing for you and noting in your posts.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 53 guests