mercredi 15 juin 2022

Logitech Lua Script randomized button press in repeat loop on random sleep timers

first time i try to code sth for me so....... Here i got a script that repeats (on mouse button 5 press) pushing multiple buttons with random sleep timers each after one another, checking after each button, if mouse button is still pressed. Working fine so far. Sorry for the chaotic look.

Goal:

  • holding down button 5
    • Pressing assigned buttons (7,8,w,q,f,s) in random order,
    • random sleep timers,
    • check after each random button press if mouse button is still pressed

Remaining Problem:

  • repeating same button order while holding down mouse button 5 (not randomized)

After hours of research i couldn't find somethin that helps me with that problem by myself, so i thought i'll try it here!

I really would appreciate some help here :)))

    EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
      repeat
        PressKey("8")
         Sleep(math.random(16, 21)) 
         ReleaseKey("8") 
if not IsMouseButtonPressed(5) then break end
 Sleep(math.random(13, 47)) 
        PressKey("7")
         Sleep(math.random(16, 38)) 
         ReleaseKey("7") 
if not IsMouseButtonPressed(5) then break end
 Sleep(math.random(13, 47)) 
        PressKey("w")
         Sleep(math.random(43, 87)) 
         ReleaseKey("w") 
if not IsMouseButtonPressed(5) then break end
 Sleep(math.random(10, 49)) 
        PressKey("q")
         Sleep(math.random(16, 38)) 
         ReleaseKey("q") 
if not IsMouseButtonPressed(5) then break end
 Sleep(math.random(13, 47)) 
        PressKey("w")
         Sleep(math.random(43, 87)) 
         ReleaseKey("w") 
if not IsMouseButtonPressed(5) then break end
 Sleep(math.random(13, 47)) 
        PressKey("f")
         Sleep(math.random(15, 63)) 
         ReleaseKey("f") 
if not IsMouseButtonPressed(5) then break end
 Sleep(math.random(13, 47)) 
        PressKey("s")
         Sleep(math.random(16, 28)) 
         ReleaseKey("s") 
if not IsMouseButtonPressed(5) then break end
      until not IsMouseButtonPressed(5)
end



Aucun commentaire:

Enregistrer un commentaire