有人可以结合这两个脚本

时间:2020-06-07 01:24:47

标签: lua logitech-gaming-software

无法使它正常工作。第一部分是切换功能(鼠标按钮8),该功能通过按下和释放鼠标按钮1来发挥作用。第二部分(鼠标按钮7)只是“点击使用”功能。

我可以翻转这些部分,而只有第二部分有效,这让我感到困惑。

function OnEvent(event, arg)
    OutputLogMessage("event = %s, arg = %d\n", event, arg)
        if (event == "PROFILE_ACTIVATED") then
            EnablePrimaryMouseButtonEvents(true)
        elseif event == "PROFILE_DEACTIVATED" then
            ReleaseMouseButton(2) -- to prevent it from being stuck on
        end
        if (event == "MOUSE_BUTTON_PRESSED" and arg == 8) then
            recoil = not recoil
            spot = not spot
        end
        if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then
            if recoil then
                repeat
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 23)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 24)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 21)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 23)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 27)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 26)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 25)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                until not IsMouseButtonPressed(1)
            end
        end
    end
function OnEvent(event, arg)
    if (event == "MOUSE_BUTTON_PRESSED" and arg == 7) then
        MoveMouseTo(39805, 60267)
        Sleep(30)
        PressMouseButton(1)
        Sleep(50)
        ReleaseMouseButton(1)
        Sleep(50)
        MoveMouseTo(32805, 50267)
        Sleep(25)
        PressMouseButton(1)
        Sleep(30)
        ReleaseMouseButton(1)
    end
end

谢谢。

1 个答案:

答案 0 :(得分:1)

想通了

function OnEvent(event, arg)
    OutputLogMessage("event = %s, arg = %d\n", event, arg)
        if (event == "PROFILE_ACTIVATED") then
            EnablePrimaryMouseButtonEvents(true)
        elseif event == "PROFILE_DEACTIVATED" then
            ReleaseMouseButton(2) -- to prevent it from being stuck on
        end
        if (event == "MOUSE_BUTTON_PRESSED" and arg == 8) then
            recoil = not recoil
            spot = not spot
        end
        if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then
            if recoil then
                repeat
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 23)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 24)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 21)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 23)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 27)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 26)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-1, 25)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(16, 4)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                MoveMouseRelative(-16, 0)
                Sleep(100) if not IsMouseButtonPressed(1) then break end
                until not IsMouseButtonPressed(1)
            end

    elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 7) then
        MoveMouseTo(16000, 61000)
        Sleep(30)
        PressMouseButton(1)
        Sleep(50)
        ReleaseMouseButton(1)
        Sleep(50)
        MoveMouseTo(32805, 50267)
        Sleep(25)
        PressMouseButton(1)
        Sleep(30)
        ReleaseMouseButton(1)
    end
end