开发者

Holding down the left mouse button in AutoHotkey

开发者 https://www.devze.com 2022-12-15 02:43 出处:网络
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 t开发者_运维百科he key again.

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 t开发者_运维百科he key again.

How can I do that?


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


Here is a one-liner in case anyone is interested:

F1::Click % GetKeyState("LButton") ? "Up" : "Down"


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
0

精彩评论

暂无评论...
验证码 换一张
取 消