【问题标题】:Instantly abort Lua Script立即中止 Lua 脚本
【发布时间】:2021-11-12 17:43:34
【问题描述】:

当我按下鼠标 1 时,脚本将按住“x”键 5000 毫秒,等待 200 毫秒并重复循环,直到我松开鼠标 1。

问题是即使我提前释放键,脚本也会运行 5000 毫秒,如果我释放鼠标 1,寻找立即退出脚本的方法。

谢谢????

EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if IsKeyLockOn("numlock" )then
                if IsMouseButtonPressed(1) then


    repeat
            PressKey("x")
Sleep(5000)
ReleaseKey("x")
Sleep(200)



                    until not IsMouseButtonPressed(1)


        end                     
    end
end

【问题讨论】:

    标签: lua logitech logitech-gaming-software


    【解决方案1】:

    将 5 秒分成 200 毫秒的小间隔

    EnablePrimaryMouseButtonEvents(true)
    function OnEvent(event, arg)
      if IsKeyLockOn("numlock" )then
        if IsMouseButtonPressed(1) then
          repeat
            PressKey("x")
            for i = 1, 5000/200 do
              Sleep(200)
              if not IsMouseButtonPressed(1) then break end
            end
            ReleaseKey("x")
            Sleep(200)
          until not IsMouseButtonPressed(1)
        end                     
      end
    end
    

    【讨论】:

      猜你喜欢
      • 2020-03-12
      • 2010-12-09
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 2010-12-07
      • 2012-08-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多