这是我的尝试,使罗技高精度的延迟,精确到1ms。
为什么你需要高精度的延迟?因为从2004年Win10发布开始,Logitech Sleep(1)
实际上已经睡了15.6ms,所以您可能需要一个更精确的Sleep()
来保留旧脚本的原始(Win10 1909)行为。
function Sleep3(time)
local a = GetRunningTime()
while GetRunningTime()-a < time do
end
end
Sleep3()
的精确度真的等于1ms吗?
发布于 2022-01-21 09:05:59
罗技GetRunningTime()
刚刚调用WinAPI函数GetTickCount
正如你从医生那里看到的,
GetTickCount函数的分辨率仅限于系统定时器的分辨率,通常在10毫秒到16毫秒之间。
换句话说,GetRunningTime()
返回的值不是顺序整数。
当您在循环中调用GetRunningTime()
时,您将收到如下内容:
...,0,15,15,15,...,15,31,31,..,31,46,46,.
这意味着它无法使用GetRunningTime()
实现1ms精度的延迟。
Sleep3()
的实际精度为15 as,和通常的Sleep()
一样。
发布于 2022-01-25 08:00:38
function OnEvent(event,arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 4 then
a = GetRunningTime()
for i = 1,1000,1 do
Sleep(1)
end
OutputLogMessage((GetRunningTime() - a) / 1000)
end
end
https://stackoverflow.com/questions/70795608
复制相似问题