【问题标题】:Logitech G Hub script - The code keeps running sometimes even after I release left mouse罗技 G Hub 脚本 - 即使在我松开​​鼠标左键后,代码有时仍会继续运行
【发布时间】:2020-09-21 15:08:45
【问题描述】:

即使在我松开​​鼠标左键后,脚本有时仍会自行单击,我该如何停止。

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
            if IsMouseButtonPressed(1) then
                repeat
                    Sleep(math.random(50, 75))
                    PressMouseButton(1)
                    Sleep(math.random(50, 75))
                    ReleaseMouseButton(1)
                until not IsMouseButtonPressed(1)
            end             
end

【问题讨论】:

  • 为什么你使用同一个按钮来触发你正在模拟从事件内部按下的事件?

标签: lua logitech logitech-gaming-software


【解决方案1】:

不可能同时模拟 LMB 按下/释放并确定它是按下还是释放。

但有一种解决方法:您可以为与 LMB 相同的操作添加替代按钮。
例如,如果 LMB 表示“开火”,则添加键“P”作为游戏中开火的替代方式。

local key_fire = "P"
EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
      Sleep(math.random(100, 150))
      while IsMouseButtonPressed(1) do
         Sleep(math.random(50, 75))
         PressKey(key_fire)
         Sleep(math.random(50, 75))
         ReleaseKey(key_fire)
      end
   end
end

您通过按 LMB 进行第一次拍摄,脚本将通过在循环中以编程方式按 P 进行第二次、第三次、...拍摄。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-06
    • 2021-08-13
    • 2021-04-22
    • 2021-10-07
    • 2020-10-03
    • 2020-03-06
    • 2022-08-18
    • 2021-04-16
    相关资源
    最近更新 更多