Send Click While Holding Mouse Button Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Phroster
Posts: 17
Joined: 10 Mar 2017, 06:35

Send Click While Holding Mouse Button

18 Oct 2017, 18:31

Code: Select all

~*q::
Send {shift down}
Click
Send {shift up}
return
The problem I have with this code, is that when I hold the left mouse button, press Q, the script gets executed, but afterwards the mouse button will go into a released state.
So the game won't register me holding the left mouse button anymore, I have to click again and hold, to get the button working again.
It seems this happens because AHK sends a release state after sending the click, but this interferes with the mouse.
Is there a way to work around this ?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Send Click While Holding Mouse Button  Topic is solved

18 Oct 2017, 22:01

You can try an If GetKeyState("LButton","P") check just before the Click. You can decide if the LButton is held down, it should just do an artificial Click down. Otherwise it should do a Click.


But then you may need to tweak this for your use in that maybe you can just skip the click completely? Is it fine for your program/game if you use LButton down first, then press Shift, to trigger what you want?
Phroster
Posts: 17
Joined: 10 Mar 2017, 06:35

Re: Send Click While Holding Mouse Button

19 Oct 2017, 07:23

Yes thank you.

I made this, and it works, it keeps holding if I'm holding the button, if not it clicks.

Code: Select all

Send {shift down}
random, time, 25, 33
sleep, time
GetKeyState, state, Lbutton, P
if state = D
Send {Lbutton down}
else
Send {Lbutton}
random, time, 25, 33
sleep, time
Send {shift up}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], RandomBoy and 262 guests