罗技Lua睡眠行为 [英] Logitech Lua Sleep Behavior

查看:186
本文介绍了罗技Lua睡眠行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Egor总是会提供帮助,因此它旨在向他显示问题,但是如果您知道如何解决,请也提供帮助!

Since Egor always help, this is intended to show him the problem, but if you know how to solve, please help too!

https://youtu.be/J2vRfnUplio <<<这就是脚本的工作方式.(有关更多信息,请参见说明)

https://youtu.be/J2vRfnUplio <<< this is how the script should work. (look at the descripition for more info)

https://youtu.be/HH_MmfXUdl8 <<<在Windows较新的版本中,这就是现在的做法.

https://youtu.be/HH_MmfXUdl8 <<< This is how it doing now, at windows newer versions.

在LUA上的MouseMoveRelative上使用Sleep()函数有问题

^^这是显示问题的最后一个问题,您在那里帮助了我

^^ This is the last question that shows the problem and you helped me there

GHUB的版本相同,所以GHUB不是问题.

GHUB has the same version on both, so isnt GHUB the problem.

Sleep(1)不会表现出应有的状态,我最好的猜测是Windows更改了某些内容,但问题出在哪里.

Sleep(1) wont behave like it should, my best guess is that windows changed something but WHAT is the question.

有人帮忙吗?

推荐答案

在脚本的开头插入以下代码块

Insert the following block of code at the beginning of your script

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)函数一段较短的时间间隔.

After that you can use function FastSleep(delay) in your script for small time intervals.

示例:

FastSleep(0.5)  -- wait for 0.5 ms

对于较大的时间间隔(例如30毫秒或更长时间),首选标准 Sleep().

For big time intervals (for example, 30 ms or more) standard Sleep() is preferred.

这篇关于罗技Lua睡眠行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆