Teachers, I have a question about Logitech g-hub

211 views Asked by At

The problem with the script that's out now is that I hope it will continue to be pressed randomly while I'm pressing the button. But if I keep pressing this button "8," it will only be pressed once. I hope that if I hold the button "8" down, it will continue to be randomly pressed while I hold it down. And I hope it stops if I let go of the button. What scripts do I need to fix?

EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 8 then
        repeat
            PressMouseButton(1)
            Sleep(math.random(70,120))
            PressKey("q","s")
            Sleep(math.random(70,120))
            ReleaseMouseButton(1)
            ReleaseKey("q","s")
        until not IsMouseButtonPressed(8)
    end
end

If I press the "8" button just once and touch it, I hope it keeps clicking randomly and continuously. And hope the macro stops once I press the button "8" again.

I'd really appreciate it if you could answer me.

I tried to delete "repeat", but when I deleted it, I got an error, so I can't do this or that. And I tried to change it to

"PressAndReleaseMouseButton()"

but not only did I get a random value, but rather the speed of pressing the button was faster.

1

There are 1 answers

0
Egor Skriptunoff On

The mistake:
IsMouseButtonPressed(8) is incorrect: this function accepts only 1-5.

How to fix:
You should open GHub application and assign action "Back" to physical button 8.
After that edit your script and use IsMouseButtonPressed(4) instead of 8.
Explanation: mouse button 4 is "Backward" button, its default action is "Back", so this way button 8 acts as if it were button 4.
Of course, your game should ignore button 4 press/release (check your game controls settings to be sure of it).