How to use AHK to hold down the mouse click as long as I'm holding it?

6,487

Try this:

left::
send,{Lbutton down}
keywait,left
Send,{Lbutton up}
return

You need the keywait command because AHK will only allow one of the same hotkeys to run at a time, the keywait ensures that the current hotkey does not end until you let go of the key. Thus when the autorepeat does kick in AHK does not fire the hotkey again because it is already running.

Share:
6,487

Related videos on Youtube

Triple C
Author by

Triple C

Updated on September 18, 2022

Comments

  • Triple C
    Triple C over 1 year

    Here is my code atm..

    ; Create hotkey for the 'left' key
    left::
    Click , 53, 486
    return
    
    ; Create hotkey for the 'down' key
    down::
    Click , 138, 613
    return
    
    ; Create hotkey for the 'right' key
    right::
    Click , 227, 543 
    return
    
    ; Create hotkey for the 'up' key
    up::
    Click , 136, 476
    return
    

    I tried using Click {Down up} or {Up down} but it holds it down forever.. How do I make it those button hold down as long as I hold down my arrow keys? And stop when I release the arrow keys? Sorry I'm very confused and new :(