微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

罗技 LUA 脚本添加睡眠定时器

如何解决罗技 LUA 脚本添加睡眠定时器

想知道如何将睡眠计时器添加到我的 LUA 脚本中,这样它就不会尽可能快地循环并按 0x29,我想这样做,当我按下鼠标上的按钮 1 和 3 时,它会命中每 3-4 秒键入 0x29 一次,而不是尽可能快。

SELECT a,b,c,@var1 as d
FROM table
WHERE a = '@var2' 

解决方法

您可以通过 GetRunningTime()

以毫秒为单位获取当前时间
local last_time = -math.huge
local is_pressed = {}

function OnEvent(event,arg)
    if event == "PROFILE_ACTIVATED" then
        EnablePrimaryMouseButtonEvents(true)
    elseif event == "MOUSE_BUTTON_RELEASED" and (arg == 1 or arg == 2) then
        is_pressed[arg] = false
    elseif event == "MOUSE_BUTTON_PRESSED" and (arg == 1 or arg == 2) then
        is_pressed[arg] = true
        local mb1 = is_pressed[1]
        local mb2 = is_pressed[2]
        --OutputLogMessage(tostring(mb1) .. " - " .. tostring(mb2))
        if mb1 and mb2 and GetRunningTime() - last_time > 5000 then
            PressAndReleaseKey(0x29)
            last_time = GetRunningTime()
        end
    end
end

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。