<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Sleep короче 10 мс]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18306&amp;type=atom" />
	<updated>2024-10-18T10:13:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=18306</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Sleep короче 10 мс]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161690#p161690" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>спасибо за ответ. </p><p>Если (!!!) интерпретатор LUA в LGS использует стандартную системную функцию, а не что-то свое.</p>]]></content>
			<author>
				<name><![CDATA[RacalCucumber]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41299</uri>
			</author>
			<updated>2024-10-18T10:13:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161690#p161690</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Sleep короче 10 мс]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161648#p161648" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>RacalCucumber пишет:</cite><blockquote><p>Есть ли еще какие то способы получить короткие значения Sleep из AHK?</p></blockquote></div><p>Сам AHK или LUA тут не при чём, минимальный интервал зависит от разрешения системного таймера, которое в обычном режиме соответствует примерно 15 мс. Winapi функция timeBeginPeriod может уменьшить это разрешение (что вызывает повышенную нагрузку на систему).</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-09-27T14:17:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161648#p161648</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Sleep короче 10 мс]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161647#p161647" />
			<content type="html"><![CDATA[<p>Да, спасибо, я читал https://www.autohotkey.com/docs/v1/lib/Sleep.htm и видел пример с изменением параметра timeBeginPeriod и вызова Sleep через DLL. </p><p>Два вопроса. <br />- Есть ли еще какие то способы получить короткие значения Sleep из AHK?<br />- В оболочке логитеха G-Hub для игровой переферии в сценарии Lua короткие задержки реализуются через вызов следующей подпрограммы:<br /></p><div class="codebox"><pre><code>function Sleep_Short(time)
    local a = GetRunningTime()
    while GetRunningTime()-a &lt; time do
    end
end
</code></pre></div><p>Ни кто не знает, насколько данное решение в Lua сходна с AHK решением из примера в статье про Sleep?</p><div class="codebox"><pre><code>SetBatchLines -1  ; Ensures maximum effectiveness of this method.

SleepDuration := 1  ; This can sometimes be finely adjusted (e.g. 2 is different than 3) depending on the value below.
TimePeriod := 3 ; Try 7 or 3.  See comment below.
; On a PC whose sleep duration normally rounds up to 15.6 ms, try TimePeriod:=7 to allow
; somewhat shorter sleeps, and try TimePeriod:=3 or less to allow the shortest possible sleeps.

DllCall(&quot;Winmm\timeBeginPeriod&quot;, &quot;UInt&quot;, TimePeriod)  ; Affects all applications, not just this script&#039;s DllCall(&quot;Sleep&quot;...), but does not affect SetTimer.
Iterations := 50
StartTime := A_TickCount

Loop %Iterations%
    DllCall(&quot;Sleep&quot;, &quot;UInt&quot;, SleepDuration)  ; Must use DllCall instead of the Sleep command.

DllCall(&quot;Winmm\timeEndPeriod&quot;, &quot;UInt&quot;, TimePeriod)  ; Should be called to restore system to normal.
MsgBox % &quot;Sleep duration = &quot; . (A_TickCount - StartTime) / Iterations</code></pre></div>]]></content>
			<author>
				<name><![CDATA[RacalCucumber]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41299</uri>
			</author>
			<updated>2024-09-27T08:15:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161647#p161647</id>
		</entry>
</feed>
