Holding down the left mouse button in AutoHotkey

Pizza Overflow picture Pizza Overflow · Jan 2, 2010 · Viewed 51.2k times · Source

I want a script where pressing F1 makes AutoHotkey hold down the left mouse button. I then want the script to release the mouse once I press the key again.

How can I do that?

Answer

DaMacc picture DaMacc · Jan 3, 2010

I would use Click down and Click up

Click is generally preferred over MouseClick because it automatically compensates if the user has swapped the left and right mouse buttons via the system's control panel.

F1::
    alt := not alt
    if (alt)
    {
        Click down
    }
    else
    {
        Click up
    }
Return