Sequences of two button presses. Logitech G Hub lua script

192 views Asked by At

The script is activated only when the right and then the left mouse button is clicked first. I need to be able to activate the script by any sequence of pressing these two buttons.

I tried putting (event == "MOUSE_BUTTON_PRESSED" and arg == 3) together/before/after (event == "MOUSE_BUTTON_PRESSED" and arg == 1), but the script didn't want to activate in any way.

function OnEvent(event, arg)

if (event == "MOUSE_BUTTON_PRESSED" and arg == 1) and IsMouseButtonPressed(3) then
    repeat
        MoveMouseRelative(1 , 1) 
        if not IsMouseButtonPressed(1) then break end
    until not IsMouseButtonPressed(1)
end

if (event == "PROFILE_ACTIVATED") then
    EnablePrimaryMouseButtonEvents(true)
end

end

1

There are 1 answers

0
ESkri On

Include both variants in the condition: (arg == 1 and IsMouseButtonPressed(3) or arg == 2 and IsMouseButtonPressed(1))

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" and (arg == 1 and IsMouseButtonPressed(3) or arg == 2 and IsMouseButtonPressed(1)) then
      repeat
         MoveMouseRelative(1, 1)
         Sleep(10)
      until not IsMouseButtonPressed(1)
   end
end