<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Ограничение вызова OnMessage() рамками одного окна GUI.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11974&amp;type=atom" />
	<updated>2016-10-06T20:08:00Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11974</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ограничение вызова OnMessage() рамками одного окна GUI.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=108239#p108239" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>	if (A_Gui == 11 || !A_Gui)
		return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-10-06T20:08:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=108239#p108239</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ограничение вызова OnMessage() рамками одного окна GUI.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=108231#p108231" />
			<content type="html"><![CDATA[<p>Здоровья всем.<br /></p><div class="codebox"><pre><code>
strDay := strHour := strMin := &quot;&quot;
while (A_Index &lt;= 31) {
	if (A_Index - 1 &gt; 0) 
		strDay := % strDay A_Index-1 &quot;|&quot;
	else
		strDay := % strDay A_Index-1 &quot;||&quot;
}
while (A_Index &lt;= 24) {
	if (A_Index - 1 &gt; 0) 
		strHour := % strHour A_Index-1 &quot;|&quot;
	else
		strHour := % strHour A_Index-1 &quot;||&quot;
}
while (A_Index &lt;= 60) {
	if (A_Index - 1 == 7) 
		strMin := % strMin A_Index-1 &quot;||&quot;
	else
		strMin := % strMin A_Index-1 &quot;|&quot;
}
OnMessage(0x202, &quot;bttnClick&quot;)
Gui, 11: +ToolWindow +AlwaysOnTop
Gui, 11: Add, Text, x5 y5,Дней:
Gui, 11: Add, ComboBox, x55 y5 w50 vwaitDay, %strDay%
Gui, 11: Add, Text, x5 y30,Часов:
Gui, 11: Add, ComboBox, x55 y30 w50 vwaitHour, %strHour%
Gui, 11: Add, Text, x5 y55,Минут:
Gui, 11: Add, ComboBox, x55 y55 w50 vwaitMin, %strMin%
Gui, 11: Add, Button, x5 y80 h18,Ждать
Gui, 11: Add, Button, x55 y80 h18,Не ждать
Gui, 11: Show,, Ожидать

waitTimer := -1
while (waitTimer == -1)
	sleep, 100
	
waitTimer += UnixTime()
while (UnixTime() &lt; waitTimer) {
	;ControlSetText, Static2, % TimeFormat(waitTimer - UnixTime()), ahk_id %LogHwnd%
	;отправляет в контрол окна оставшееся время
	sleep 999
}
return
11ButtonНеждать:
	waitTimer := 0
	Gui, 11: Destroy
return
11ButtonЖдать:
	Gui, 11: Submit, NoHide
	waitTimer := (waitDay*1440+waitHour*60+waitMin)*60
	Gui, 11: Destroy
return
bttnClick() {
	if (A_Gui == 11)
		return
	Global clickReturn, guiReturn, bttnNmbr
	Static newCntrl, oldClick, oldGUI, oldBttn
	if (newCntrl != A_GuiControl) {
		newCntrl := A_GuiControl
		ctrlNameArr := StrSplit(A_GuiControl, A_Space)
		oldBttn := bttnNmbr := ctrlNameArr[1]
		oldClick := clickReturn := ctrlNameArr[2]
		oldGUI := guiReturn := A_Gui
		ToolTip
		Gui, %guiReturn%: Show, Hide
	} else {
		clickReturn := oldClick
		guiReturn := oldGUI
		bttnNmbr := oldBttn
		ToolTip
		Gui, %guiReturn%: Show, Hide
	}
}
TimeFormat(time_param) {
	time_sec := time_param
	time_min := 0
	time_hour := 0
	
	while (time_sec &gt; 3599) {
		time_sec -= 3600
		time_hour++
	}
	while (time_sec &gt; 59) {
		time_sec -= 60
		time_min++
	}
	if (StrLen(time_hour) == 1)
		time_hour := % &quot;0&quot; time_hour
	if (StrLen(time_min) == 1)
		time_min := % &quot;0&quot; time_min
	if (StrLen(time_sec) == 1)
		time_sec := % &quot;0&quot; time_sec
	
	return % time_hour &quot;:&quot; time_min &quot;:&quot; time_sec
}
; https://autohotkey.com/board/topic/2486-code-to-convert-fromto-unix-timestamp/
;###############Convert YYYYMMDDHHMISS into Unix timestamp#############
UnixTime() {
	time_orig=%A_NOW%

	StringLeft, now_year, time_orig, 4
	StringMid, now_month, time_orig, 5, 2
	StringMid, now_day, time_orig, 7, 2
	StringMid, now_hour, time_orig, 9, 2
	StringMid, now_min, time_orig, 11, 2
	StringRight, now_sec, time_orig, 2

	;Get year seconds
	year_sec := 31536000*(now_year - 1970)

	;Determine how many leap days
	leap_days := (now_year - 1972)/4 + 1
	Transform, leap_days, Floor, %leap_days%

	;Determine if date is in a leap year, and if the leap day has been yet
	this_leap := now_year/4
	Transform, this_leap_round, Floor, %this_leap%
	If (this_leap = this_leap_round)
	  {
	  If now_month &lt;= 2
		leap_days--   ;subtracts 1 because this year&#039;s leap day hasn&#039;t been yet
	  }
	leap_sec := leap_days*86400

	;Determine fully completed months
	If now_month = 01
	  month_sec = 0
	If now_month = 02
	  month_sec = 2678400
	If now_month = 03
	  month_sec = 5097600
	If now_month = 04
	  month_sec = 7776000
	If now_month = 05
	  month_sec = 10368000
	If now_month = 06
	  month_sec = 13046400
	If now_month = 07
	  month_sec = 15638400
	If now_month = 08
	  month_sec = 18316800
	If now_month = 09
	  month_sec = 20995200
	If now_month = 10
	  month_sec = 23587200
	If now_month = 11
	  month_sec = 26265600
	If now_month = 12
	  month_sec = 28857600

	  
	;Determine fully completed days
	day_sec := (now_day - 1)*86400

	;Determine fully completed hours
	hour_sec := now_hour*3600 ;don&#039;t subtract 1 because it starts at 0

	;Determine fully completed minutes
	min_sec := now_min*60

	;Calculate total seconds
	date_sec := year_sec + month_sec + day_sec + leap_sec + hour_sec + min_sec + now_sec
	return date_sec
}
</code></pre></div><p>Функция bttnClick() участвует в работе других GUI, поэтому она изолируется обозначенным ранее в этой теме способом от GUI, получающего значения времени о задержке перед следующим событием:<br /></p><div class="codebox"><pre><code>
if (A_Gui == 11)
		return
</code></pre></div><p>Но клики по полям выпадающих списков комбобокса приводят к - &quot;Error: Invalid Gui name&quot;. В принципе, не особо и проблема, потому как можно и кнопками нужное число набрать, или вообще заменить ComboBox на Edit, но всё же, может быть есть решение? Подскажите пожалуйста.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2016-10-06T11:11:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=108231#p108231</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ограничение вызова OnMessage() рамками одного окна GUI.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107276#p107276" />
			<content type="html"><![CDATA[<p>А вот и не всё так просто, как показалось. Все контролы GUI теперь безжизненны. Переход на метки при клацании по кнопкам и прочим элементам не происходит. Это означает, что теперь внутри одной функции придётся разместить все подпрограммы, вызывая их при сравнении с A_GuiControl, верно?</p><p>UPD:<br />Прошу прощения, забыл на метках номер GUI указать. Теперь всё работает. Ещё раз моя благодарность. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2016-09-02T22:50:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107276#p107276</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ограничение вызова OnMessage() рамками одного окна GUI.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107252#p107252" />
			<content type="html"><![CDATA[<p>И то верно! Всё гениальное - просто. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Благодарю.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2016-09-02T08:31:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107252#p107252</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ограничение вызова OnMessage() рамками одного окна GUI.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107249#p107249" />
			<content type="html"><![CDATA[<p>Вызовы по-любому будут. Но вы можете проверять, для какого окна произошёл вызов, и действовать соответственно. Проверяйте переменную A_Gui, и если номер не тот, делайте Return без параметров, чтобы пропустить сообщение дальше.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2016-09-02T02:26:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107249#p107249</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Ограничение вызова OnMessage() рамками одного окна GUI.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107247#p107247" />
			<content type="html"><![CDATA[<p>Всем доброго настроения.<br />Подскажите пожалуйста, как ограничить функциональность OnMessage() в границах окна GUI с определённым номером? Чтобы в окнах с другими номерами не происходило вызовов.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2016-09-01T23:25:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107247#p107247</id>
		</entry>
</feed>
