0

what I want to do is if I press the button on my mouse it uses a key like "E" and if I press the button again it uses the key "W", one more time press button "e", and again "w".
Is that possible?

I find this but it's not realy what i want:
https://stackoverflow.com/a/62067519/17803151

local prev_tm_btn5 = -math.huge

function OnEvent(event, arg, family)

   if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then

      local tm = GetRunningTime()

      local key = tm - prev_tm_btn5 > 2000 and "e" or "w"

      prev_tm_btn5 = tm

      PressKey(key)

      Sleep(15)

      ReleaseKey(key)

   end

end

thank you !

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
john86
  • 3
  • 1

1 Answers1

0

Try:

local key

function OnEvent(event, arg, family)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
      key = key == "w" and "e" or "w"
      PressKey(key)
      Sleep(15)
      ReleaseKey(key)
   end
end
Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64