Holding down the left mouse button in AutoHotkey

感情迁移 提交于 2019-12-04 17:51:19

问题


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?


回答1:


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



回答2:


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

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



回答3:


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


来源:https://stackoverflow.com/questions/1993003/holding-down-the-left-mouse-button-in-autohotkey

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!