Search code examples
lualogitechlogitech-gaming-software

Trying to assign middle click button to LUA autoclicker script (Logitech G203 Mouse)


I was wondering how I would make this autoclicker turn on whenever I would click on the middle (scroll) button of my mouse. This script seems to work when I press on one of my side buttons, but I can't seem to figure out how to make it work for my middle button.

EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
   --OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
   if event == "MOUSE_BUTTON_PRESSED" and arg == 4 then 
      repeat 
         PressAndReleaseMouseButton(1)
         Sleep(math.random(30, 60)) 
      until not IsMouseButtonPressed(4) 
   end
end

Solution

  • Logitech Mouse Buttons enumeration is non-trivial :-)

    EnablePrimaryMouseButtonEvents(true)
    function OnEvent(event, arg)
       --OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
       if event == "MOUSE_BUTTON_PRESSED" and arg == 3 then -- 3 = middle
          repeat 
             PressAndReleaseMouseButton(1)
             Sleep(math.random(30, 60)) 
          until not IsMouseButtonPressed(2) -- 2 = middle
       end
    end