尝试在 Lua 脚本中调用空值

我想创建一个简单的脚本,通过 Logitech 游戏软件在 Lua 中不断点击鼠标左键。然而,它在"EnablePrimaryMouseButtonEvents (true)"这一行上不断报错"尝试调用空值" 下面是我的脚本:

EnablePrimaryMouseButtonEvents (true)

function OnEvent(event, arg)
  if IsKeyLockOn("scrolllock") then
    if IsMouseButtonPressed(1) then
      repeat
        PressMouseButton(1)
        Sleep(15)
      until not IsMouseButtonPressed(1)
    end
  end
end
点赞