<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: автообновление gui]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17127&amp;type=atom" />
	<updated>2022-05-16T20:45:58Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17127</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: автообновление gui]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153229#p153229" />
			<content type="html"><![CDATA[<p>Тут правда в строке &#039;UnixTimeToLocal(Time, -5, &quot;hh:mm:ss&quot;)&#039; необходимо подставить своё значение часового смещения вместо &#039;-5&#039;.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-05-16T20:45:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153229#p153229</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: автообновление gui]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153228#p153228" />
			<content type="html"><![CDATA[<p><strong>__Михаил__</strong> , благодарю, снова меня выручаете.</p>]]></content>
			<author>
				<name><![CDATA[yura170100]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41910</uri>
			</author>
			<updated>2022-05-16T20:03:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153228#p153228</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: автообновление gui]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153227#p153227" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>CustomColor2 = EEAA99

Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 0
Gui, Font, s7 w4300
Gui, Add, Text, cWhite, Время:
Gui, Add, Text, cWhite vTT x5 y24, Загрузка
Gui, Show, x5 y10 NA

WinSet, TransColor, %CustomColor2% 200
Winset, ExStyle, +0x20
SetTimer, GetTime, 1000
Return


UGet(U){
 E := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;), E.Open(&quot;GET&quot;,u), E.Send(), E.WaitForResponse(), R:=E.ResponseText, E=
 Return R
}

GetTime(){
 Static Time := UGet(&quot;https://time100.ru/api.php&quot;)
 GuiControl,, TT, % UnixTimeToLocal(Time, -5, &quot;hh:mm:ss&quot;)
 Time++
}

UnixTimeToLocal(UnixTime, Diff := 0, FormatStr := &quot;&quot;){
 Time := &quot;19700101&quot;
 Time += UnixTime, s
 Time += Diff, h
 If FormatStr
  FormatTime, Time, % Time, % FormatStr
 Return Time
}</code></pre></div><p>Мой вариант загружает с сайта один раз, обновляет время без цикла. Лишнее удалил.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-05-16T19:03:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153227#p153227</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: автообновление gui]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153226#p153226" />
			<content type="html"><![CDATA[<p>&#039;GuiControl&#039; для этого есть.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-05-16T18:23:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153226#p153226</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: автообновление gui]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153225#p153225" />
			<content type="html"><![CDATA[<p>Добрый день. Имеется ahk, которая ретранслирует время с сайта <a href="http:////time100.ru/">Time100</a> через gui. Обновление времени должно происходить каждую секунду, смог реализовать только через цикл, в начале которого gui открывается, а в конце закрывается. Возможны ли какие-то варианты, чтобы gui обновлялся без постоянного закрытия и открытия?<br />Код:<br /></p><div class="codebox"><pre><code>

GetTimeFromTime100ru(localTimeOffset := 0, formatString := &quot;&quot;) {
   static url := &quot;https://time100.ru/api.php&quot;
   unixTime := GetResponseText(url,,,, error)
   if error
      throw error
   Return UnixTimeToLocal(unixTime, localTimeOffset, formatString)
}

GetResponseText(url, method := &quot;GET&quot;, HeadersArray := &quot;&quot;, body := &quot;&quot;, ByRef error := &quot;&quot;) {
   Whr := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
   Whr.Open(method, url, true)
   for name, value in HeadersArray
      Whr.SetRequestHeader(name, value)
   Whr.Send(body)
   Whr.WaitForResponse()
   status := Whr.status
   if (status != 200)
      error := &quot;HttpRequest error, status: &quot; . status
   Arr := Whr.responseBody
   pData := NumGet(ComObjValue(arr) + 8 + A_PtrSize)
   length := arr.MaxIndex() + 1
   Return StrGet(pData, length, &quot;UTF-8&quot;)
}

UnixTimeToLocal(unixTime, diff, formatStr := &quot;&quot;) {
   time := &quot;19700101&quot;
   time += unixTime, s
   time += diff, h
   if formatStr
      FormatTime, time, % time, % formatStr
   Return time
}
Loop
{
DllCall(&quot;ShowCursor&quot;, UInt, 0)
CustomColor2 = EEAA99

Gui +LastFound +AlwaysOnTop -Caption +ToolWindow +Disabled
GuiControl, Disable, Tab
Gui, Color, black

Gui, Font, s7

Gui, Font, cWhite

Gui, Font, w4300

GUI, ADD, TEXT,,      Time100
GUI, ADD, TEXT,,      % GetTimeFromTime100ru(3, &quot;HH:mm:ss&quot;)

WinSet, TransColor, %CustomColor2% 200
Winset, ExStyle, +0x20
Gui, Show, NoActivate x5 y10, My Window
Sleep, 100
Gui Destroy

}
!2::
reload
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[yura170100]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41910</uri>
			</author>
			<updated>2022-05-16T18:18:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153225#p153225</id>
		</entry>
</feed>
