罗技 Lua 睡眠行为 [英] Logitech Lua Sleep Behavior
问题描述
因为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屋!