首页 > 解决方案 > 按住人民币后按钮并点击

问题描述

我想不通。

我正在尝试完成这样的事情:

  1. 按下 GUI 按钮
  2. 当我单击鼠标下一步时按住人民币
  3. 当我再次点击释放人民币

目前的工作:

    Toggle=0
    GUI, Add, Button, w50 h50, Nbutton
    GUI, Show, x50 y50
    return

    ButtonNButton:
    {
        Toggle:=!Toggle
    }

    if GetKeyState("LButton","P")
        if (Toggle == 1)
            MsgBox, Do
            Toggle:=!Toggle
    return

标签: autohotkey

解决方案


这应该可以完成你想要的。

请注意,目前,此示例脚本仅限于在记事本中工作。您应该更新脚本以针对您希望热键处于活动状态的任何程序/游戏/窗口。

Toggle := 0
GUI, Add, Button, w50 h50, Nbutton
GUI, Show, x50 y50
return

ButtonNButton:
    Toggle:=!Toggle


    ; Update this line to match whatever window you want the hotkey active
    ; in, or delete this line to make the hotkey active everywhere.
    Hotkey, IfWinActive, ahk_class Notepad


    if Toggle
    {
        Hotkey, ~*LButton Up, RBSwitch, On
    }
    else
    {
        if GetKeyState("RButton") ;release RButton when hotkey is disabled
            Send {RButton Up}
        Hotkey, ~*LButton Up, RBSwitch, Off
    }
RETURN


RBSwitch:
    if GetKeyState("RButton")
        Send {RButton Up}
    else
        Send {RButton Down}
RETURN

推荐阅读