结合两个Lua脚本?

时间:2020-03-04 04:07:32

标签: lua logitech

我正在尝试找到一种方法来组合这两个脚本:

    function OnEvent(event, arg)
      OutputLogMessage("event = %s, arg = %d\n", event, arg)
      if (event == "PROFILE_ACTIVATED") then
        EnablePrimaryMouseButtonEvents(true)
      elseif event == "PROFILE_DEACTIVATED" then
        ReleaseMouseButton(2)  -- to prevent it from being stuck on
      end
      if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
        recoilx2 = not recoilx2
        spot = not spot
      end
      if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoilx2) then
        if recoilx2 then
          repeat
            MoveMouseRelative(0, 25)
            Sleep(1000)
          until not IsMouseButtonPressed(1)
        end
      end

      if IsMouseButtonPressed(1) then
        repeat
          PressMouseButton(1)
          Sleep(15)
          ReleaseMouseButton(1)
        until not IsMouseButtonPressed(1)
      end
    end

当我按鼠标5激活第一部分时,底部的重复单击部分不起作用。

1 个答案:

答案 0 :(得分:0)

当我按鼠标5激活第一部分时,重复 底部的单击部分无效。

当您第一次按下按钮5时,您最终出现在该条件语句中

 if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
   recoilx2 = not recoilx2
   spot = not spot
 end

这会将true分配给recoilx2

此后按下按钮1时,您将得到以下条件语句:

if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoilx2) then
  if recoilx2 then
    repeat
      MoveMouseRelative(0, 25)
      Sleep(1000)
    until not IsMouseButtonPressed(1)
  end
end

您在这里等到不再按下按钮1。

除非再次按下按钮5来将false分配给recoilx2,否则当您按下按钮1时始终会停留在那里,直到释放按钮1为止。

因此,您永远不能输入此条件语句。

 if IsMouseButtonPressed(1) then
   repeat
     PressMouseButton(1)
     Sleep(15)
     ReleaseMouseButton(1)
   until not IsMouseButtonPressed(1)
 end
相关问题