title: Rapid fire with logitech lua script?
body: <p>When writing lua scripts for my logitech g502, I've gotten rapid fire to work, but it will continue to execute mouse presses after the mouse one button is released as long as the ctrl key is held. I am wondering if there is any kind of iteration that would allow me to signal a function that presses and releases the mouse but under the conditional that the same mouse button is pressed.(For example, ctrl must be held and rapid fire only executes when mouse button 1 is held down, as opposed to until ctrl is released).</p>
  
  <p>Here is the code I am referring to </p>
  
  <pre><code>EnablePrimaryMouseButtonEvents(true);
  
  function OnEvent(event, arg)
      if IsModifierPressed("lctrl") then
          repeat  
              if IsMouseButtonPressed(1) then
                  repeat
                      PressMouseButton(1)
                      Sleep(15)
                      ReleaseMouseButton(1)
                  until not IsMouseButtonPressed(1)
              end             
          until not IsModifierPressed("lctrl")
      end         
  end
  </code></pre>
  
  <p>I am wondering if there is any kind of iteration that would allow me to signal a function that presses and releases the mouse but under the conditional that the same mouse button is pressed.(For example, ctrl must be held and rapid fire only executes when mouse button 1 is held down, as opposed to until ctrl is released).</p>
  
  <p>Alternatives I have considered: binding fire to another key that isn't mouse button 1, and having it repeated when mouse button one is pressed.</p>
  
  <p>Thanks in advance</p>