<?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=12939&amp;type=atom" />
	<updated>2017-08-23T21:53:26Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12939</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Таймеры]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=118715#p118715" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>с глобальными переменными gui не сложилось</p></blockquote></div><p>Всё правильно, переменных gui в таком случае лучше избегать, думаю любую задачу можно решить без них.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-23T21:53:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=118715#p118715</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Таймеры]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=118711#p118711" />
			<content type="html"><![CDATA[<p>Я пробовал написать класс для создания произвольного кол-ва gui таймеров, но что-то с глобальными переменными gui не сложилось и забросил. Для двух-трех написать то несложно, но лень.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-08-23T20:42:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=118711#p118711</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Таймеры]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=118692#p118692" />
			<content type="html"><![CDATA[<p>Много кода и мало понятно что точно требуется. Но если надо выводить графически, можете <a href="http://forum.script-coding.com/viewtopic.php?pid=118563#p118563">это посмотреть</a>.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-23T16:01:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=118692#p118692</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Таймеры]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=118689#p118689" />
			<content type="html"><![CDATA[<p>Добрый день. В общем я делаю скрипты для своего удобства и много времени ahk до этого не уделял. Но вот у меня возникла проблема: хочу реализовать несколько таймеров по нажатию кнопки для каждого соответственно.&nbsp; Т.е. например по нажатию кнопки 1 - запускается первый таймер на экране, по нажатию кнопки 2- рядом с первым запускается второй таймер и т.д.</p><p>Нашел рабочий вариант таймера и переделал под себя, но вот как сделать что бы несколько работало - не знаю.<br />Поможете?<br /></p><div class="codebox"><pre><code>Color1 = CSILVER
Color2 = cYellow
Color3 = cAqua
Color4 = cRed
Color5 = cFuchsia
Color6 = CSILVER

Timer(Timer_Name := &quot;ti1&quot;, Timer_Opt := &quot;D&quot;)
{
	static
	global Timer, Timer_Count
	if !Timer
		Timer := {}
	if (Timer_Opt = &quot;U&quot; or Timer_Opt = &quot;Unset&quot;)
		if IsObject(Timer[Timer_Name])
		{
			Timer.Remove(Timer_Name)
			Timer_Count --=
			return true
		}
		else
			return false
	if RegExMatch(Timer_Opt,&quot;(\d+)&quot;,Timer_Match)
	{
		if !(Timer[Timer_Name,&quot;Start&quot;])
			Timer_Count += 1
		Timer[Timer_Name,&quot;Start&quot;] := A_TickCount
		Timer[Timer_Name,&quot;Finish&quot;] := A_TickCount + Timer_Match1
		Timer[Timer_Name,&quot;Period&quot;] := Timer_Match1
	}
	if RegExMatch(Timer_Opt,&quot;(\D+)&quot;,Timer_Match)
		Timer_Opt := Timer_Match1
	else
		Timer_Opt := &quot;Dq&quot;
	if (Timer_Name = &quot;&quot;)
	{
		for index, element in Timer
			Timer(index)
		return
	}
	if (Timer_Opt = &quot;R&quot; or Timer_Opt = &quot;Reset&quot;)
	{
		Timer[Timer_Name,&quot;Start&quot;] := A_TickCount
		Timer[Timer_Name,&quot;Finish&quot;] := A_TickCount + Timer[Timer_Name,&quot;Period&quot;]
	}
	Timer[Timer_Name,&quot;Now&quot;] := A_TickCount
	Timer[Timer_Name,&quot;Left&quot;] := Timer[Timer_Name,&quot;Finish&quot;] - Timer[Timer_Name,&quot;Now&quot;]
	Timer[Timer_Name,&quot;Elapse&quot;] := Timer[Timer_Name,&quot;Now&quot;] - Timer[Timer_Name,&quot;Start&quot;]
	Timer[Timer_Name,&quot;Done&quot;] := true
	if (Timer[Timer_Name,&quot;Left&quot;] &gt; 0)
		Timer[Timer_Name,&quot;Done&quot;] := false
	if (Timer_Opt = &quot;D&quot; or Timer_Opt = &quot;Done&quot;)
		return Timer[Timer_Name,&quot;Done&quot;]
	if (Timer_Opt = &quot;S&quot; or Timer_Opt = &quot;Start&quot;)
		return Timer[Timer_Name,&quot;Start&quot;]
	if (Timer_Opt = &quot;F&quot; or Timer_Opt = &quot;Finish&quot;)
		return Timer[Timer_Name,&quot;Finish&quot;]
	if (Timer_Opt = &quot;L&quot; or Timer_Opt = &quot;Left&quot;)
		return Timer[Timer_Name,&quot;Left&quot;]
	if (Timer_Opt = &quot;N&quot; or Timer_Opt = &quot;Now&quot;)
		return Timer[Timer_Name,&quot;Now&quot;]
	if (Timer_Opt = &quot;P&quot; or Timer_Opt = &quot;Period&quot;)
		return Timer[Timer_Name,&quot;Period&quot;]
	if (Timer_Opt = &quot;E&quot; or Timer_Opt = &quot;Elapse&quot;)
		return Timer[Timer_Name,&quot;Elapse&quot;]
}

;
Time_Remaining = 0
Show_OSD = 2
CustomColor = %Color1%  
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow  
Gui, Color, %CustomColor%
Gui, Font,  s18  ; Set a large font size (32-point).
Gui, Add, Text, vMyText %Color6%, XXXXX YYYYY  
WinSet, TransColor, %CustomColor% 500
SetTimer, UpdateOSD, 200
Gosub, UpdateOSD  
Gui, Show, x1366 y-15 NoActivate  
return
;

MsToMinSec(i) {
	Return, i &lt; 1 ? &quot;0:0&quot; : ((n := i // g := 60000) ? n : &quot;0&quot;) . &quot;:&quot;
		. ((0 &lt; i -= n * g) ? ((n := i // 1000) ) : &quot;0&quot;)
} 

UpdateOSD:
MS_Left := 660000-Timer(&quot;Timer&quot;,&quot;L&quot;)
Time_Left := MsToMinSec(MS_Left)
if Time_Remaining &gt; 0 
 {
  Gui, Font, %Color5%
  GuiControl, Font, MyText
  GuiControl,, MyText, Stop
 }
else if (Timer(&quot;Timer&quot;,&quot;S&quot;) and !Timer(&quot;Timer&quot;)) {
 if MS_Left between 0 and 300000
 {
  Gui, Font, %Color4%
  GuiControl, Font, MyText
 }
 else if MS_Left between 300001 and 480000 
 {
  Gui, Font, %Color3%
  GuiControl, Font, MyText
 }
 else if MS_Left between 480001 and 660000
 {
  Gui, Font, %Color2%
  GuiControl, Font, MyText
 } 
 GuiControl,, MyText, %Time_Left%
}
else 
{
 Gui, Font, %Color6%
 GuiControl, Font, MyText
 GuiControl,, MyText, Up!
}
return

sc2::
 if Time_Remaining &gt; 0
 {
  Timer(&quot;Timer&quot;,Time_Remaining)
  Time_Remaining = 0
 }
 else if (Timer(&quot;Timer&quot;,&quot;S&quot;) and !Timer(&quot;Timer&quot;))
 {
  Time_Remaining := Timer(&quot;Timer&quot;,&quot;L&quot;)
  Timer(&quot;Timer&quot;,&quot;U&quot;)
 }
 else
  Timer(&quot;Timer&quot;,660000)
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[sergey22]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38730</uri>
			</author>
			<updated>2017-08-23T14:38:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=118689#p118689</id>
		</entry>
</feed>
