<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Пауза скрипта по системному времени]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15476&amp;type=atom" />
	<updated>2020-06-27T01:56:50Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15476</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140392#p140392" />
			<content type="html"><![CDATA[<p>В общем понял я, что задача здесь не совсем тривиальная. Я нашел для себя более простой способ: по нужному мне времени в планировщике задач запускается файл, который убивает процесс с AHK, затем запускается другой AHK файл, где прописана часть кода от &quot;убитого&quot; файла без цикла. Поэтому, если даже планировщик &quot;убьет&quot; скрипт при выполнении части кода, пока скрипт не ждет команды sleep, второй файл завершит прерванную работу.<br />Спасибо всем, кто хотел помочь.<br />P.S. конкретно в моем случае не критично, если часть кода скрипта после прерывания работы будет повторно выполнена. Самое главное, чтобы код был выполнен полностью, потому что в конце кода выполняется действие, которое даёт возможность выполняться корректно циклу после ожидания команды sleep. В ином случае, первый цикл будет сделан &quot;вхолостую&quot;. Как-то так <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[vitek19841210]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40934</uri>
			</author>
			<updated>2020-06-27T01:56:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140392#p140392</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140389#p140389" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>__Михаил__ пишет:</cite><blockquote><p>С &#039;SubStr&#039; не знаком</p></blockquote></div><p>Так а почему бы не познакомиться? Документация в свободном доступе. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> В данном случае мы берём символы с первого по восьмой из значения переменной A_Now, т. е. год, месяц и число. Далее командой Format форматируем заданное время на случай, если оно задано в виде 9:00 — просто добавляем нули до четырёх знаков. В принципе этот шаг можно было пропустить, если есть уверенность, что время задано в виде 09:00, и просто написать<br /></p><div class="codebox"><pre><code>alarmTime := SubStr(now, 1, 8) . StrReplace(alarmTime, &quot;:&quot;) . &quot;00&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-06-26T20:32:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140389#p140389</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140386#p140386" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>SetTimer minuteDisplay, 60000
minuteDisplay:
msgbox current minutes: %A_Min%</code></pre></div>]]></content>
			<author>
				<name><![CDATA[EV]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40256</uri>
			</author>
			<updated>2020-06-26T20:13:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140386#p140386</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140385#p140385" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Вооот, вот именно умного подхода мы все и ждём)</p><p>Понятно сразу, что правильно высчитать нужное время и затем уже ждать столько времени.<br />Почему я не стал этого делать? Быстро на ум пришла простая идея сверки текущего времени по таймеру, который можно настроить как угодно.<br />Более сложного решения искать уже не стал.</p><p>С &#039;SubStr&#039; не знаком, а с &#039;Format&#039; имел дело лишь копируя чужой код.</p><p>Было бы очень интересно получить комментарии к строкам Вашего кода, точнее только этой строки:</p><div class="codebox"><pre><code>alarmTime := SubStr(now, 1, 8) . Format(&quot;{:04}00&quot;, StrReplace(alarmTime, &quot;:&quot;))</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-06-26T19:29:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140385#p140385</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140384#p140384" />
			<content type="html"><![CDATA[<p>Если нужно просто засечь определённое время, не обязательно проверять время каждую минуту. Достаточно поставить таймер на разницу в милисекундах между нужным временем, и текущим:<br /></p><div class="codebox"><pre><code>#Persistent
alarmTime = 22:00

now := A_Now
alarmTime := SubStr(now, 1, 8) . Format(&quot;{:04}00&quot;, StrReplace(alarmTime, &quot;:&quot;))
alarmTime -= now, s
if (alarmTime &lt; 0)
   alarmTime := 86400 + alarmTime
SetTimer, Alarm, % alarmTime * 1000
Return

Alarm:
   MsgBox, Alarm!
   ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-06-26T19:00:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140384#p140384</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140380#p140380" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Основная моя задача была показать реализацию срабатывания участка кода строго по времени.<br />Это лишь пример, без учёта остальных условий.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-06-26T18:06:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140380#p140380</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140376#p140376" />
			<content type="html"><![CDATA[<p>Погодите, а разве ваш код справляется с задачей?<br /></p><div class="quotebox"><cite>vitek19841210 пишет:</cite><blockquote><p>если вдруг, в это определенное время еще исполняется основной код (скрипт не ждет тайминга команды Sleep) - чтобы остановка произошла сражу же после выполнения основного кода</p></blockquote></div><p>Тут должна ещё обрабатываться ситуация, когда таймер срабатывает во время какого-то циклического действия, и он должен ждать его завершения.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-06-26T17:38:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140376#p140376</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140368#p140368" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong></p><p>Будет интересно посмотреть на Ваш, возможно более элегантный код...</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-06-26T16:36:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140368#p140368</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140367#p140367" />
			<content type="html"><![CDATA[<p><strong>vitek19841210</strong></p><p>F2 - кнопка запуска.<br />TimeWait - время ожидания перед очередной проверкой.<br />TimeOut - время (час:мин).</p><br /><div class="codebox"><pre><code>F2::
TimeWait := 1000*	60			; Время между проверкой времени (раз в минуту).
TimeOut = 21:27					; Время срабатывания.
SetTimer, Alarm, %TimeWait%		; Запускаем таймер.
Return


Alarm:
T := % A_Hour . &quot;:&quot; . A_Min
If (T &gt;= TimeOut)
{
 SetTimer, Alarm, Off			; Вырубаем таймер.
 MsgBox,8256, Время наступило: %T%, Таймер сработал!
}
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-06-26T16:33:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140367#p140367</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140365#p140365" />
			<content type="html"><![CDATA[<p><strong>__Михаил__</strong>, ну тут каждый вправе по-своему оценивать своё время.<br />Лично я считаю количество потраченных часов*стоимость часа работы, но минимально не менее определенного количества часов (занимаюсь непрограммированием).</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-06-26T16:23:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140365#p140365</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140361#p140361" />
			<content type="html"><![CDATA[<p><strong>__Михаил__</strong>, бросьте, какие 100 руб, копеек 50 красная цена. Или даже 30.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-06-26T16:08:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140361#p140361</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140360#p140360" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong></p><p>За подобный, простой код? Уж больно дорого. Максимальная цена ~100 Руб.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-06-26T16:06:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140360#p140360</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140356#p140356" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>__Михаил__ пишет:</cite><blockquote><p>Если нет желания учиться - лучше это забросить сразу.</p></blockquote></div><p>Почему же, есть коммерческий раздел, где, думаю, за 20-30 евро напишут.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-06-26T15:38:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140356#p140356</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140353#p140353" />
			<content type="html"><![CDATA[<p><strong>vitek19841210</strong><br />Таким макаром далеко не уйти. Если тупо всё копировать, то наверняка будут косяки с одинаковыми именами переменных, меток перехода и прочее.<br />Если нет желания учиться - лучше это забросить сразу.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2020-06-26T15:18:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140353#p140353</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Пауза скрипта по системному времени]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=140319#p140319" />
			<content type="html"><![CDATA[<p>Друзья, спасибо за ответы. В теории, как это будет работать, я понял. Но навыков программирования недостаточно, чтобы самостоятельно написать код. Обычно просто ищу уже готовые варианты через поисковые системы, и вставляю в свои скрипты. В этот раз найти ничего не удалось. Поэтому написал на этот форум. Если не затруднит, хотелось бы увидеть готовый код.</p>]]></content>
			<author>
				<name><![CDATA[vitek19841210]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40934</uri>
			</author>
			<updated>2020-06-25T21:05:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=140319#p140319</id>
		</entry>
</feed>
