修改 LUA 脚本以允许鼠标在一定时间内在右键单击后紧接着左键按下 Alt 键

我的朋友在游戏中使用了这个 Logitech 鼠标的 LUA 脚本,如果他单击并按住右鼠标按钮,然后再点击左鼠标按钮,则执行“按下左 Alt 键”的操作:

function OnEvent(event,arg)
    if IsKeyLockOn("numlock")then
        if IsMouseButtonPressed(3)then
            repeat
                if IsMouseButtonPressed(1) then
                    PressAndReleaseKey("lalt")
                    repeat
                    until not IsMouseButtonPressed(1)
                end
            until not IsMouseButtonPressed(3)
        end
    end
end

我有不同的设置,我不是单击并按住右鼠标按钮,而只是单击它一次,我的左键单击可能立即跟随或在 1-2 秒后。 因此,我需要脚本仅在我单击右鼠标按钮并立即或在 2 秒内单击左鼠标按钮时执行“按下左 Alt 键”的操作。

你能帮我吗?谢谢!

点赞
用户1847592
用户1847592
local RMB_time = -math.huge

function OnEvent(event, arg)
    if event == "PROFILE_ACTIVATED" then
        EnablePrimaryMouseButtonEvents(true)
    elseif event == "MOUSE_BUTTON_PRESSED" and arg == 2 then  -- 按下右键
        RMB_time = GetRunningTime()
    elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 then  -- 按下左键
        if IsKeyLockOn"numlock" and GetRunningTime() - RMB_time < 2000 then
            Sleep(20)
            PressKey("lalt")
            Sleep(50)
            ReleaseKey("lalt")
        end
    end
end
2020-11-21 09:16:02