Reputation: 11
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
Upvotes: 1
Views: 11527
Reputation: 23747
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:
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.LSHIFT_BUTTON_PRESSED
, you receives events only from G-buttons (all buttons on Logitech mouse and special G-buttons on Logitech keyboard).PressKey
is not the same as presskey
Upvotes: 1