0
votes

I'm trying to make a script that will press the RButton after holding the LButton for a specific amount of time and ignore the left click. I don't know how to go about this.

Pseudo code:

timer = 0;

while(LButton down){
add 1 to timer?

if(timer==100){
Send {RButton}
ignore LButton
reset timer
}
}
1

1 Answers

1
votes

Use A_TickCount as a quick and easy way of measuring the passing of time.

(TESTED)

LButton::
StartTime := A_Tickcount
WaitTimeInMilliSeconds = 1000
tooltip trying
while(StartTime+WaitTimeInMilliSeconds > A_Tickcount)
{
     if(!GetKeyState("LButton","P"))
     {
         click ;send the click anyway if it's not held.
         return
     }
}
tooltip this happens after 1000 milli second of continuously holding left mouse button
return

If you put this inside a left mouse button hotkey it will reset itself automatically. If you want it looping all the time, you can put the entire thing in an endless loop and reset the starttime instead of return