I wrote a simple Lua script that left clicks after I click mouse5. The issue is, on line 12 if I include 'not' it will only repeat once, if I remove it, it will repeat forever. I want to start and end the script with mouse5 if possible. I know people have had similar issues to mine before, but I was unable to find a solution. Any ideas?
I am using the Logitech G Hub API: (https://douile.github.io/logitech-toggle-keys/APIDocs.pdf)
And this for my loop: (https://www.tutorialspoint.com/lua/lua_repeat_until_loop.htm)
My code:
function OnEvent(event, arg)
OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
repeat
Sleep(math.random(1046, 1292))
PressMouseButton(1)
Sleep(math.random(27, 78))
ReleaseMouseButton(1)
Sleep(math.random(314, 664))
until not IsMouseButtonPressed(5)
end
end
end