Logitech Lua 睡眠行为

由于 Egor 总是帮忙,这是为了向他展示问题,但如果你知道如何解决,请也帮助一下!

https://youtu.be/J2vRfnUplio <<<< 这是脚本应该如何工作的视频。 (查看说明获取更多信息)

https://youtu.be/HH_MmfXUdl8 <<<< 这就是它在较新版本的 Windows 上的运行情况。

Having problems with Sleep() func on MouseMoveRelative on LUA

^^ 这是显示问题并且你在那里帮了我最后一个问题

GHUB 在两个版本上都是相同的,因此 GHUB 不是问题所在。

Sleep(1) 的行为不会像它应该的那样,我最好的猜测是 Windows 更改了某些东西,但是问题是什么。

有人能帮忙吗?

点赞
用户1847592
用户1847592

OnEvent()函数之前,将以下代码块插入脚本的开头

do
   local function busyloop(final_ctr)
      final_ctr = final_ctr - final_ctr%1
      local ctr, prev_ms, ms0, ctr0 = 0
      while ctr ~= final_ctr do
         local ms = GetRunningTime()
         if prev_ms and ms ~= prev_ms then
            if not ms0 then
               ms0, ctr0 = ms, ctr
            elseif final_ctr < 0 and ms - ms0 > 500 then
               return (ctr - ctr0) / (ms - ms0)
            end
         end
         prev_ms = ms
         ctr = ctr + 1
      end
   end
   local coefficient = busyloop(-1)
   function FastSleep(ms)
      return busyloop(ms * coefficient)
   end
end

然后,您可以在脚本中使用 FastSleep(delay) 函数进行短时间间隔的等待。

例如:

FastSleep(0.5)  -- 等待0.5毫秒

对于长时间间隔(例如30毫秒或更长),建议使用标准的Sleep()函数。

2020-12-18 17:54:54