luamacroslogitech-gaming-software

Do not record key presses when pressed in GHUB/Logitech Gaming Software


I made this script with LUA in GHUB:

function OnEvent(event, arg)
    if IsMouseButtonPressed(5) then
        PressKey("r")
        Sleep(math.random(30, 100))
        ReleaseKey("r")
        Sleep(math.random(30, 100))
    end
end

But I don't want mouse button 5 to be detected. In fact, if I try to press it, it will record the pressure of key 5 and then it starts the script. Is there a way to press the key without it being detected?

You can open this image to understand better

I thought that to do this I could create a macro instead of a script but I need a random delay. How can I solve?


Solution

  • I'm not sure I have understood you correctly, but this is the obvious steps:

    1. Check event and arg in the script instead of IsMouseButtonPressed:
    function OnEvent(event, arg)
        if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
            PressKey("r")
            Sleep(math.random(30, 100))
            ReleaseKey("r")
        end
    end
    
    1. If you want to disable Mouse Button 5 be "detected" when you press it:
      Go to GHUB (mouse device, "Assignments" screen).
      Unassign standard command "Forward" from physical MB#5 (click and select DISABLE from the drop-down menu).
      Disabled MB#5 will look like a white circle with black inside.