English 中文(简体)
Holding down the left mouse button in AutoHotkey
原标题:
  • 时间:2010-01-02 21:54:45
  •  标签:
  • autohotkey

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?

最佳回答

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




相关问题
How do you control a .NET checkbox from AutoHotKey?

I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is not directly controllable in AutoHotKEy using "Control,...

How can I rename my visual studio taskbar button?

I often work with multiple checkouts of the same solution, but as they all have the same name, all the taskbar buttons appear the same. I would like to rename the taskbar buttons so I can identify ...

Run AutoHotkey script when screen locked?

I ve written a couple of scripts with AutoHotkey, but I notice they only work when a user is logged in and the screen isn t locked. I d like to schedule the script to run. Does anyone know if that ...

AutoHotKey key SEQUENCE, not just single-key hotkey

I m not stupid... really. How do you map a key SEQUENCE (ie: Ctrl + Q , F) in AutoHotKey. I ve got Ctrl + Q down: ^q:: I ve even got F: f:: The examples in the help files even show how to do two ...

Where is the source code for AutoScriptWriter

I am using autohotkey for test now but tired with modifying the "Sleep, 100" generated by autoscriptwriter. So I decided to get the source code and see if I can modify it a little bit to fit my needs ...

Holding down the left mouse button in AutoHotkey

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?

热门标签