1

I'm trying to have two inputs that will lead to one output. This is so I can use an ability in a game thanks if you can help.

function OnEvent(event, arg) 
     if event == "MOUSE_BUTTON_PRESSED" and arg == 2 then --set flag for mb2
            mb2_pressed = true
    elseif event == "MOUSE_BUTTON_RELEASED" and arg == 2 then --set flag for mb2=false
        mb2_pressed = false
    else if event == "LSHIFT_BUTTON_PRESSED" and arg == 1 then
    leftshift_pressed = true
    else if event == "LSHIFT_BUTTON_RELEASED" and arg == 1 then
    leftshift_pressed = false
    end
end

if leftshift_pressed and  if mb2_pressed then
presskey("9")
        Sleep(50)
        releasekey("9")
end
end

https://gyazo.com/7e7f2139fabb22d1e06f8f3f169cb4bb

2

1 Answer 1

1
function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 2 and IsModifierPressed("lshift") then
      PressAndReleaseKey("lshift")
      PressAndReleaseKey("9")
   end
end

You should know the following:

  • LGS/GHUB has a bug in line numbering, "line 12" in error message actually means line#13 in your code (and red stripe is also set at wrong position)
  • if leftshift_pressed and if mb2_pressed then is a syntax error, you should write if leftshift_pressed and mb2_pressed then
  • if/elseif/else/end must be balanced. Yours are not. Use indentation in the code to make it obvious.
  • There is no event LSHIFT_BUTTON_PRESSED, you receives events only from G-buttons (all buttons on Logitech mouse and special G-buttons on Logitech keyboard).
  • Uppercase is different from lowercase: PressKey is not the same as presskey
Sign up to request clarification or add additional context in comments.

6 Comments

thanks its kind of working but instead of ouputting 9 its displaying a "("
Yes, while shift is down, key 9 is treated as (
thx for helping however that one doesnt work well what was the old code before?
What exactly doesn't work well? You can see previous versions of the answer by clicking at "edited XX mins ago" link
in this version after I use the macro shift is staying pressed / staying on even even after the key presses. Its just weird.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.