Press AND hold button

Get help with using AutoHotkey and its commands and hotkeys
Posts: 1
Joined: 25 Apr 2019, 15:28

Press AND hold button

25 Apr 2019, 15:32


I want my mouse button to be both held down and pressed multiple times while holding down, is this possible? I want to use the LMB for both these things and I don't want to include a modifier to distinguish.

Code: Select all

This is my code:
#MaxHotkeysPerInterval 900000
SendMode Input

Send {LButton} 					// just for regular clicking
sleep 40						// just for regular clicking
While GetKeyState("LButton", "P")	// repetitive clicking + holding down mouse button
        Send {LButton down}
        Sleep 7 
Send {LButton up}
I lack a proper testing method to see if it's working at all right now, but I've recognized at least one error already. Sometimes the application I'm using it on won't register the mouse buttons release.
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Press AND hold button

25 Apr 2019, 19:15

I think that this is all that you need:

Code: Select all

~LButton::								; The ~ allows regular clicking
Sleep, 400								; Wait so that quick single clicks don't process the While loop
While(GetKeyState("LButton", "P"))
        Send, {LButton}
        SoundPlay, *48
        Sleep, 700
I added the SoundPlay line simply to show you a handy way to test hard-to-test scripts like this. I also increased the Sleep below it simply so that you can hear the sound effect play more clearly and know that the loop is, well, looping.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], teadrinker, yjs778 and 217 guests