1

我的罗技 G500 有一个小宏 - 我在 FPS 游戏中使用它来减少后坐力。请看下面的脚本:

EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 1  then
        repeat
            MoveMouseRelative(-1,2)
            Sleep(16)
        until not IsMouseButtonPressed(1)
    end
end

问题是这个脚本一直在工作。我希望按下另一个按钮 1 以开始在按钮 2 上使用脚本并重新按下按钮 1 以中断脚本

我试图设置标志,例如:

unction OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then --set flag for mb1
                mb1_pressed = true
        elseif event == "MOUSE_BUTTON_RELEASED" and arg == 6 then --set flag for mb1=false
        mb1_pressed = false
        end 

If mb1_pressed then
    if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and  then
        repeat
            MoveMouseRelative(-1,2)
            Sleep(16)
        until not IsMouseButtonPressed(1)
    end

end  

但它不起作用。请你帮助我好吗 ?

4

1 回答 1

1
 if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then --set flag for mb1
            mb1_pressed = true
 elseif event == "MOUSE_BUTTON_RELEASED" and arg == 6 then --set flag for mb1=false
    mb1_pressed = false
 end

这将mb1_pressed在按下鼠标按钮时设置,并在释放时取消设置。因此,该变量仅在按下按钮时为真。

如果您想mb1_pressed在每次按下时切换值,您可以执行类似的操作

if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then --toggle flag for mb1
            mb1_pressed = not mb1_pressed
end
于 2014-10-30T14:09:45.270 回答