【问题标题】:what is making my logitech LUA code not work?是什么让我的罗技 LUA 代码不起作用?
【发布时间】:2021-12-04 14:17:27
【问题描述】:

我最近在修复我的 Logitech autoclicker 脚本以删除代码中的错误时得到了一些帮助,现在 logitech ghub 似乎认为代码是有效的,除了每次我尝试使用它时,我得到的最多就是单击它而不是在我按住左键时每 20-80 毫秒点击 1 次。 提前感谢任何能够提供帮助的人

代码如下:

EnablePrimaryMouseButtonEvents(true);
function OnEvent(event,arg)
    if IsKeyLockOn("capslock") then
        if IsMouseButtonPressed(3) then
            repeat
                if IsMouseButtonPressed(1) then
                    repeat
                        PressAndReleaseMouseButton(1)
                        Sleep(math.random(20,60))
                    until not IsMouseButtonPressed(1)
                end
            until not IsMouseButtonPressed(3)
        end
    end
end

【问题讨论】:

  • 如果您松开鼠标按钮 1 并在按住鼠标按钮 3 的同时再次单击它会发生什么?

标签: lua logitech


【解决方案1】:

您的代码完全按照其编写方式运行;因为只要启用了大写锁定,鼠标右键被按住并且鼠标左键被按住它会继续点击你的随机间隔等待时间。但是,它只单击一次的原因是因为正在调用“Press And RELEASE”,这意味着在该调用之后不再按住鼠标左键,这会破坏您的重复循环。如果按住鼠标右键并且可以正常工作,请尝试这样做。

EnablePrimaryMouseButtonEvents(true);
function OnEvent(event,arg)
    if IsKeyLockOn("capslock") then
        if IsMouseButtonPressed(3) then
            repeat
              PressAndReleaseMouseButton(1)
              Sleep(math.random(20,60))
            until not IsMouseButtonPressed(3)
        end
    end
end

【讨论】:

    【解决方案2】:

    您不能同时模拟 LMB 按下并监听其状态。
    最简单的解决方案是为游戏分配另一个键而不是 LMB。
    我假设你已经分配了 P 键进行拍摄。

    function OnEvent(event, arg)
       if event == "PROFILE_ACTIVATED" then
          EnablePrimaryMouseButtonEvents(true)
       elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
          if IsKeyLockOn("capslock") and IsMouseButtonPressed(3) then
             repeat
                PressKey("P")
                Sleep(math.random(20,60))
                ReleaseKey("P")
                Sleep(math.random(20,60))
             until not IsMouseButtonPressed(1)
          end
       end
    end
    

    【讨论】:

      猜你喜欢
      • 2021-04-10
      • 2019-08-30
      • 2021-08-14
      • 2015-02-04
      • 2020-03-10
      • 2014-01-23
      • 2013-08-06
      • 2013-10-25
      相关资源
      最近更新 更多