tags:

views:

963

answers:

3

i want to press F1 and then make autohotkey hold the mouse left button and when i press again he releases it

how can i do that?

A: 

Mmm, I am a bit rusty in AHK programming, but here is what I tried, seems to work:

F1::
  alt := not alt
  If (alt)
  {
    MouseClick Left, 217, 51, , , D
  }
  Else
  {
    MouseClick Left, 217, 51, , , U
  }
Return
PhiLho
Using MouseClick is overkill and makes it look more complicated. Click Up/ Down should suffice.
SyaZ
Yes, that's what did DaMacc...
PhiLho
+2  A: 

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
}
DaMacc
A: 

(Written here since i cannot comment yet)

@DaMacc: I've needed to add Return at the end of the hotkey procedure code to make it work for me.

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