Search code examples
lualogitech-gaming-software

Lua help off switch


Hi im totally new to scripting. im using this currently and it works the way i want even with the error, moves down only once on each press. What i want is if i press "v" it will turn "numlock" off if its on and leave off if off. Help would be great

function OnEvent(event, arg)
    if (event == "PROFILE_ACTIVATED") then
        EnablePrimaryMouseButtonEvents(true)
    end
    if IsKeyLockOn("numlock") then
        if (event == "MOUSE_BUTTON_PRESSED" and arg == 1)then
            if IsMouseButtonPressed(3)then
                repeat
                    MoveMouseRelative(0, 30)
                    Sleep(10)
                    MoveMouseRelative(0, 30)
                    Sleep(10)
                    MoveMouseRelative(0, 30)
                    Sleep(10)
                until not IsMouseButtonPressed()
            end
        end
    end
end

Solution

  • What i want is if i press "v"

    GHUB is unable to handle press/release of usual keys on the keyboard (digits, letters).
    GHUB allows you to write handle for:

    • mouse buttons (on Logitech mouse)
    • special G-keys and M-keys (on Logitech keyboard)

    In other words, GHUB is unable to do something when user presses V


    it will turn "numlock" off if its on and leave off if off

    You can do this, for example, on mouse button 5 press:

    if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
       if IsKeyLockOn"NumLock" then
          PressAndReleaseKey"NumLock"
       end
    end