Logitech G hub lua脚本

EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)
    --OutputLogMessage("事件: "..event.." 参数: "..arg.."\n")
  if (event == "MOUSE_BUTTON_PRESSED" and arg == 11) then
    repeat
      PressAndReleaseMouseButton(1)
      Sleep(1,2)
    until not MOUSE_BUTTON_PRESSED("11")
  end
end

我做了这个, 但是在第一行出现了一个错误, 但我不确定问题出在哪里。

原文链接 https://stackoverflow.com/questions/71269155

点赞
stackoverflow用户1847592
stackoverflow用户1847592

有两个错误:

  • Sleep(1,2) 是错误的:

    Sleep 需要一个参数 - 一个整数毫秒数。

    例如,使用 Sleep(10)

  • MOUSE_BUTTON_PRESSED("11") 是未知的函数。

如果您想确定按钮 #11 是否按下:

  1. 在 G Hub 的用户界面中将命令 "Back" 分配给鼠标按钮 #11;
  2. 在脚本中使用 IsMouseButtonPressed(4)
function OnEvent(event, arg)
    --OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
  if event == "MOUSE_BUTTON_PRESSED" and arg == 11 then
    repeat
      PressAndReleaseMouseButton(1)
      Sleep(10)
    until not IsMouseButtonPressed(4)
  end
end
2022-02-25 18:05:20