0
votes
LButton::
^LButton::
 While GetKeyState("LButton","p"){
  Send {LButton}
  Sleep 20
 }
return

This is my current script. What it does is when I hold the left mouse button it simulates pressing it repeatedly every 20 milliseconds. But, because in the game I use it with I often have to hold Alt down to crouch I need it to work with ^LButton. But for some reason, when holding alt+LButton it just acts normally i.e. it reverts to me holding down the left mouse button.

One thing I thought of is possibly adding

While GetKeyState("LButton","p") or GetKeyState("alt LButton","p"){

However I am lacking proper syntax to pass a modifier along with a button to the GetKeyState function.

I searched through the documents and did a bit of googling but it seems like the AHK forums have been inactive for around 5 years now. If anyone knows how to solve this issue your help would be appreciated!

1
^ is Ctrl, ! is Alt.CherryDT
Also, if you do GetKeyState then the modifier doesn't matter because Alt and LButton would be two individual keys.CherryDT

1 Answers

0
votes

@CherryDT Thanks for the quick response. I actually think I was just googling the wrong because I have solved it.

The trick is that with mouse buttons, you have to use a different syntax and also there is a precedence to the order in which the combination is pressed.

LButton::
Alt + LButton::
etc...

Again, thanks for the response :)