当鼠标按键按下时,按下键盘键的脚本

我正在尝试使用lua脚本为我的罗技鼠标下达命令,当按下主键时,键盘中的一个键也被点击,直到我停止按住鼠标键

我尝试了这个,但是它可以完美地处理所有鼠标按钮,但是在为主键设置时没有任何动作发生。

function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
      PressKey("V")
   end
   if event == "MOUSE_BUTTON_RELEASED" and arg == 1 then
      ReleaseKey("V")
   end
end

有什么帮助吗?

提前感谢。

点赞
用户1847592
用户1847592

默认情况下,主要鼠标按键事件被禁用。

您需要显式启用它们。

local v_pressed

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsKeyLockOn("scrolllock") then
      PressKey("V")
      v_pressed = true
   elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 and v_pressed then
      ReleaseKey("V")
   end
end

更新

脚本只在 ScrollLock LED 开启时有效。

2021-01-15 22:49:56