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
arg == 6
does make sense, butIsMouseButtonPressed(6)
does not. – Egor Skriptunoffuntil (event == "MOUSE_BUTTON_PRESSED" and arg == 6) == false
this will not work for any arg. When inside a loop, you're staying in the same event. To change event, you must exitOnEvent
– Egor Skriptunoff