Logitech Gaming Software Macro with random sleep intervals

4k views Asked by At

I am trying to make a LGS macro that repeats pressing the "P" key, while I hold a mouse button. Since I would like this macro to use random sleep intervals between each keypress, I can't use the standard Logitech GUI for that, since this only supports standard intervals. Therefore, it seems I need to use a Lua script to achieve this.

After some research I have come across a script in this forum and modified it that from my understanding should work, but unfortunately doesn't. "My" script only repeats the actions once when I press the mouse button, instead of continuously looping.

I have no idea about programming so please do not feel burdened to stay close to my script if you see a better implementation, even the sleep time parameters are random and I have no idea if those may simulate human behavior.

EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then
      repeat
         PressKey("P")
         Sleep(math.random(27, 43)) 
         ReleaseKey("p") 
         Sleep(math.random(29, 36)) 
      until IsMouseButtonPressed(6)
   end
end
1

There are 1 answers

0
Peter O. On

Egor Skriptunoff's comment:

Only first 5 buttons are available for IsMouseButtonPressed(). And the condition in the until statement should look like until not IsMouseButtonPressed(5) if you want to stop the loop on mouse button release.