Logitech Script, 第一次和第二次点击事件重置时间

我想要做的是,如果我按下鼠标上的按钮,它使用像 "E" 这样的键,如果我再次按下按钮,则使用键 "W" 并在 2 秒后重置,我的意思是,如果我未在 2 秒内按下相同的按钮,则再次使用字母 "e"。这可能吗?

我尝试了一些代码,但尚未得到结果:

  function OnEvent(event, arg, family)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
    toggle = not toggle
    if toggle then
      PressKey("e")
      ReleaseKey("e")
    else
      PressKey("w")
      ReleaseKey("w")
    end
  end
end
点赞
用户1847592
用户1847592
```lua
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

```lua
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
2020-05-28 14:41:55