<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18351&amp;type=atom" />
	<updated>2025-01-11T12:30:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=18351</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161888#p161888" />
			<content type="html"><![CDATA[<p>Можно и переменные. Я пользовался этими функциями <a href="https://forum.script-coding.com/viewtopic.php?id=17789">здесь</a>.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>  TimeSub(Time1,Time2)
  {
    T1:=Time1[1]
    T2:=Time2[1]
    ms:=Time1[2]-Time2[2]
    if (ms&lt;0)
    {
      ms+=1000
      T2+=1,Seconds
    }
    T1-=T2,Seconds
    return T1*1000+ms
  }
  TimeSubMs(Time,ValueMs)
  {
    if (ValueMs=0)
      return Time
    m:=0
    if (ValueMs&gt;0)
    {
      ms:=Time[2]-mod(ValueMs,1000)
      if (ms&lt;0)
      {
        ms+=1000
        m:=1
      }
      t:=Time[1]
      t+=-(Floor(ValueMs/1000)+m),Seconds
    }
    else
    {
      ms:=mod(-ValueMs,1000)+Time[2]
      if (ms&gt;999)
      {
        ms-=1000
        m:=1
      }
      t:=Time[1]
      t+=(Floor(-ValueMs/1000)+m),Seconds
    }
    return [t,format(&quot;{:03}&quot;,round(ms))]
  }
  TimeAddMs(Time,ValueMs)
  {
    T:=Time[1]
    T+=ValueMs//1000,Seconds
    ms:=Time[2]+mod(ValueMs,1000)
    if (ms&gt;999)
    {
      ms-=1000
      T+=1,Seconds
    }
    return [T,format(&quot;{:03}&quot;,round(ms))]
  }
  TimeToMs(Time)
  {
    FormatTime,HH,% Time,HH
    FormatTime,MM,% Time,mm
    FormatTime,SS,% Time,ss
    return HH*3600000+MM*60000+SS*1000
  }
  MsToTime(Ms)
  {
    T:=1601
    T+=Ms//1000,Seconds
    Ms:=format(&quot;{:03}&quot;,mod(Ms,1000))
    return [T,Ms]
  }
</code></pre></div></div></div><p>Выражение - это и есть переменные и их комбинации.</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2025-01-11T12:30:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161888#p161888</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161887#p161887" />
			<content type="html"><![CDATA[<p><strong>Alectric</strong><br />Если я правильно понял в FormatTime и EnvAdd используются только числа либо выражение, но не переменные, мне это не подходит.</p>]]></content>
			<author>
				<name><![CDATA[Lelouch]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=44391</uri>
			</author>
			<updated>2025-01-11T05:17:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161887#p161887</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161886#p161886" />
			<content type="html"><![CDATA[<p>Попробуй использовать <a href="https://www.autohotkey.com/docs/v1/lib/FormatTime.htm">FormatTime</a> и <a href="https://www.autohotkey.com/docs/v1/lib/EnvAdd.htm">EnvAdd</a>.</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2025-01-11T03:07:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161886#p161886</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161884#p161884" />
			<content type="html"><![CDATA[<p>Все 100500 строк нужны, чтобы продемонстрировать проблему? Сократите код до минимума, который покажет, что именно не так, но при этом нормально запустится.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2025-01-10T14:25:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161884#p161884</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161883#p161883" />
			<content type="html"><![CDATA[<p>.</p>]]></content>
			<author>
				<name><![CDATA[Lelouch]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=44391</uri>
			</author>
			<updated>2025-01-10T12:54:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161883#p161883</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161882#p161882" />
			<content type="html"><![CDATA[<p>А зачем выкладываете код по кускам? Запостите в том виде, в котором можно запустить и увидеть проблему.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2025-01-10T10:51:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161882#p161882</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Сложение секунд и минут с сохранением формата времени 00:00:00]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=161881#p161881" />
			<content type="html"><![CDATA[<p>Приветствую всех. У меня есть таймер с кнопками <a href="https://imgur.com/a/vkEcmoP">https://imgur.com/a/vkEcmoP</a>, при нажатии кнопки должно взяться время, которое указанно на таймере и прибавится к нынешнему времени, попробовал многое, но выходит результат по типу 11:02:86, либо же вообще заменяет нынешнее время на время с таймера, помогите пожалуйста с этой проблемой.<br />Код самого таймера:</p><div class="codebox"><pre><code>
StartTimer1:
    if (!Timer1Running) {
        SetTimer, UpdateTimer1, 1000
        Timer1Running := true
    }
Return
UpdateTimer1:
    if (Timer1Running &amp;&amp; Timer1Seconds &gt; 0) {
        Timer1Seconds -= 1
        Minutes1 := Floor(Timer1Seconds / 60)
        Seconds1 := Mod(Timer1Seconds, 60)
        FormattedTime1 := Format(&quot;{:02}:{:02}&quot;, Minutes1, Seconds1)
        GuiControl,, Timer1Text, %FormattedTime1% Время до свапа локи
    } else if (Timer1Seconds &lt;= 0 &amp;&amp; Timer1Running) {
        GuiControl,, Timer1Text, Time&#039;s up! Время свапа локи
        SetTimer, UpdateTimer1, Off
        Timer1Running := false
    }
Return</code></pre></div><p>Код самой кнопки:<br /></p><div class="codebox"><pre><code>ResumeTimer1:
    if (!Timer1Running) {
        SetTimer, UpdateTimer1, 1000
        Timer1Running := true
		WinActivate, Majestic RP
        SendInput, {T}
        Sleep, 500
		A_Min1 := A_Min + Minutes1
		A_Sec1 := A_Sec + Seconds1
        A_Min2 := Floor(A_Min1 / 60)
        A_Sec2 := Mod(A_Sec1, 60)
		FormattedTime0111 := Format(&quot;{:02}:{:02}:{:02}&quot;, A_Hour, A_Min2, A_Sec2)
        SendInput, /cb Таймер возобновлён, смена локации в %FormattedTime0111%
    }
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Lelouch]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=44391</uri>
			</author>
			<updated>2025-01-10T09:51:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=161881#p161881</id>
		</entry>
</feed>
