does that mean that Sleep, 5, as a workaround, will definitely always work?
The condition to update was if
more than 5 (
> 5) ms had elapsed. So you need to sleep at least 6 ms, and add one times the resolution of the clock. Consider this test script,
Code: Select all
tr:=getTimerResolution()
n := 6+tr
loop {
t1:=QPC()
dllcall("Sleep","uint", n)
;Sleep n
t2:=QPC()
if t2-t1 < 6 ; Fail
msgbox t2-t1 "`n" A_Index
}
getTimerResolution() {
DllCall("ntdll.dll\NtQueryTimerResolution", "UPtr*", MinimumResolution, "UPtr*", MaximumResolution, "UPtr*", CurrentResolution)
return CurrentResolution/10000 ; Resolutions are reported as 100-nanoseconds
}
;-------------------------------------------------------------------------------
QPC() { ; microseconds precision, borrowed from wolf_II
;-------------------------------------------------------------------------------
static Freq, init := DllCall("QueryPerformanceFrequency", "Int64P", Freq)
DllCall("QueryPerformanceCounter", "Int64P", Count)
Return (Count / Freq)*1000
}
Result with the ahk
sleep,
I got no fail with the dllcall sleep. (Limited testing ofc.)
Note that 5.9 is more than 5 (
), but
getTickCount() which is used by BIV_Caret, reports in integers, so 5.9 might be truncated to 5, which is not more than 5
Additional note, running the test script from your first post, never seem to aquire the same coords subsequently when useing
sleep 1, modified to doing it in a loop that is, try yourself.
Your functions to get the coords seems like the better option, I will take a closer look later
Cheers.