<?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=10819&amp;type=atom" />
	<updated>2015-07-31T16:52:54Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10819</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=96157#p96157" />
			<content type="html"><![CDATA[<p>Не знаю сдаюсь).</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-07-31T16:52:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=96157#p96157</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=96146#p96146" />
			<content type="html"><![CDATA[<p><strong>yalanne</strong>, нет, я имел в виду <em>именно</em> <a href="http://forum.script-coding.com/viewtopic.php?pid=96143#p96143">мои</a> два таймера. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /> Если нужно, можно представить их в виде функций, а не подпрограмм.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-07-30T12:40:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=96146#p96146</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=96145#p96145" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, Вот. Тут 3 таймера.первый работает с <strong>aa1</strong>, второй с <strong>aa2</strong> и третий показывает результат в тултип.<br /></p><div class="codebox"><pre><code>Global Atimer := [], ALabel := [],Lthread,Atime_start := []


1::
SetTimer(&quot;timer1&quot;, 0)
SetTimer(&quot;timer2&quot;, 0)
SetTimer(&quot;Get&quot;, 0)
return

SetTimer(Label, Time){
Atimer.Insert(Time + A_TickCount),    ALabel.Insert(Label),    Atime_start.Insert(A_TickCount)
if (Atimer.MaxIndex() = 1)
    SetTimer Atimer_label,10
}

Atimer_label:
if (Atimer.MaxIndex() = 0)
    SetTimer Atimer_label,off

loop % Atimer.MaxIndex()
    if (A_TickCount &gt; Atimer[A_Index]) and (A_TickCount &lt; Atimer[A_Index]+20) and (Func(ALabel[A_Index]) != 0)
    {
    d++
    hFunc := RegisterCallback(ALabel[A_Index])
    DllCall(&quot;CreateThread&quot;, UInt, 0, UInt, 0, UInt, hFunc, UInt, 0, UInt, 0, UInt, 0)
    DllCall(&quot;TerminateThread&quot;, UInt, hFunc, UInt, 0) 
    DllCall(&quot;CloseHandle&quot;, UInt, hFunc)
    Lthread := A_Index
    }
if (Atimer.MaxIndex() = d)
    {
    sleep 20
    d:=0,Atimer := [], ALabel := [],Atime_start := []
    }
return

timer1(){
settimer Timer1,10
}

timer2(){
settimer Timer2,10
}

Get(){
settimer Get,10
}


timer1:
aa1++
sleep 100
return

timer2:
aa2++
return

Get:
tooltip % aa1 &quot;`n&quot; aa2
return
</code></pre></div><p>Вот только в новом потоке не работают loop, sleep но если в том потоке запустить обычный таймер то норм).</p><p>Скрипт по идее еще сырой его надо дорабатывать.</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-07-30T12:20:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=96145#p96145</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=96143#p96143" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>yalanne пишет:</cite><blockquote><p>добился многопоточности</p></blockquote></div><p>Ну тогда это прорыв! <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Ничего, правда, не понял в вашем коде, но запустите параллельно два таких таймера:<br /></p><div class="codebox"><pre><code>#Persistent
SetTimer, Timer1, -10
SetTimer, Timer2, -10
Return

Timer1:
   Loop  {
      ToolTip % &quot;Таймер 1 — &quot; A_Index, 300, 500
      Sleep, 500
   }
   Return
   
Timer2:
   Loop  {
      ToolTip % &quot;Таймер 2 — &quot; A_Index, 500, 500
      Sleep, 500
   }
   Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-07-30T11:52:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=96143#p96143</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=96142#p96142" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Global Atimer := [], ALabel := [],Lthread,Atime_start := []

1::
SetTimer(&quot;test&quot;, 1000)
SetTimer(&quot;test&quot;, 2000)
SetTimer(&quot;test2&quot;, 5000)
return

SetTimer(Label, Time){
Atimer.Insert(Time + A_TickCount),    ALabel.Insert(Label),    Atime_start.Insert(A_TickCount)
if (Atimer.MaxIndex() = 1)
    SetTimer Atimer_label,10
}

Atimer_label:
if (Atimer.MaxIndex() = 0)
    SetTimer Atimer_label,off

loop % Atimer.MaxIndex()
    if (A_TickCount &gt; Atimer[A_Index]) and (A_TickCount &lt; Atimer[A_Index]+20) and (Func(ALabel[A_Index]) != 0)
    {
    d++
    hFunc := RegisterCallback(ALabel[A_Index])
    DllCall(&quot;CreateThread&quot;, UInt, 0, UInt, 0, UInt, hFunc, UInt, 0, UInt, 0, UInt, 0)
    DllCall(&quot;TerminateThread&quot;, UInt, hFunc, UInt, 0) 
    DllCall(&quot;CloseHandle&quot;, UInt, hFunc)
    Lthread := A_Index
    }
if (Atimer.MaxIndex() = d)
    {
    sleep 20
    d:=0,Atimer := [], ALabel := [],Atime_start := []
    }
return

test(){
msgbox % Lthread &quot;) &quot; A_ThisFunc &quot;) &quot; A_TickCount - Atime_start[Lthread]
}

test2(){
msgbox % Lthread &quot;) &quot; A_ThisFunc &quot;) &quot; A_TickCount - Atime_start[Lthread]
}</code></pre></div><p>Вот код. Вроде добился многопоточности, но каждый новый поток не на метку идет а на функцию.<br />И отчет всех таймеров идет в одном&nbsp; через массив.</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-07-30T11:26:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=96142#p96142</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=96126#p96126" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>yalanne пишет:</cite><blockquote><p>У SetTimer&#039;ов время разное может быть?<br />Эти таймеры должны&nbsp; при совпадении 2х и более запущенных таймеров, должны работать одновременно и не прерывать друг друга?</p></blockquote></div><p> Таймеры работают асинхронно, т.е. в разных потоках, но для гарантии в каждый таймер можно прописать. </p><div class="codebox"><pre><code>LabelTimer:
Thread, NoTimers
  ; Тело таймера, т.е. что он делает
Thread, NoTimers, False
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2015-07-29T22:43:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=96126#p96126</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=96039#p96039" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>monitor1_timer, monitor2_timer и т.д они все структурой отличаются друг от друга? если нет то можно все под один шаблон сделать ведь.</p></blockquote></div><p>Структура разная, в каждой созданной метке от индекса есть динамическая переменная, которая присваивает свое значение.</p><p>Вот пример реализации задачи, но почему-то в этом варианте второй заданный таймер начинает отсчет на исполнение после первого таймера.<br /></p><div class="codebox"><pre><code>
#SingleInstance Force     
#NoEnv
ListLines Off   
#Persistent 
 
 


Loop_Index := 0
Loop 2
{
    Loop_Index++
x%Loop_Index% := 1
}
Return

1::
Global oTimers := [], Start := A_TickCount
;SetTimer(&quot;other_timer&quot;, &quot;второй&quot;, 4000)
; SetTime := 
SetTimer(&quot;monitor_timer&quot;, Loop_Index, x%Loop_Index% * 2000)
SetTimer(&quot;monitor_timer&quot;, &quot;четвёртый&quot;, 5000)
;SetTimer(&quot;monitor_timer&quot;, &quot;третий&quot;, 4000)
Return

monitor_timer: 
    ; ToolTip % (A_TickCount - Start)//1000 &quot;`n`n&quot; A_ThisLabel
    MsgBox,, Label, % oTimers[oTimers.MinIndex()].Value &quot;`n`n&quot; (A_TickCount - Start)/1000 &quot; sec`n`n&quot; A_ThisLabel 
    Return

SetTimer(Label, Value, Time) {
    SetTimer, GoLabel, Off
    Set := Time 
    While oTimers.HasKey(Set)
        Set++ 
    oTimers[Set] := {Label:Label,Value:Value}
    SetTime := oTimers.MinIndex()
    ; SetTime := SetTime &lt; 1 ? 1 : SetTime
    SetTimer, GoLabel, % &quot;-&quot; SetTime 
    Return
    
    GoLabel:
        Try GoSub, % oTimers[oTimers.MinIndex()].Label
        oTimers.Delete(oTimers.MinIndex()) 
        If !oTimers.MinIndex()
            Return
        SetTime := oTimers.MinIndex()
        ; SetTime := SetTime &lt; 1 ? 1 : SetTime
        SetTimer, GoLabel, % &quot;-&quot; SetTime
        Return
} 
</code></pre></div><p>То, что подразумевается под &quot;динамической&quot; переменной:<br /></p><div class="codebox"><pre><code>x%Loop_Index% := 1</code></pre></div><p>Сама &quot;динамическая&quot; метка от этого такая:<br /></p><div class="codebox"><pre><code>monitor_timer: 
index := oTimers[oTimers.MinIndex()].Value
var%index% := &quot;unlock&quot;
Return</code></pre></div><p>Если было бы можно сделать так:<br /></p><div class="codebox"><pre><code> SetTimer, monitor_timer%Loop_Index%, 1000
monitor_timer%Loop_Index%:</code></pre></div><p>То было бы куда проще, но так, к сожалению, нельзя.</p><p>Все, что остается здесь дорешать:<br />1. Как одновременно задавать таймеры, чтобы второй запускался одновременно с первым, а не начинал свой отсчет после исполнения первого.<br />2. И чтобы второй таймер не прерывал первый, пока тот не закончит свое исполнение в заданном Label</p>]]></content>
			<author>
				<name><![CDATA[Странникх]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30605</uri>
			</author>
			<updated>2015-07-26T00:27:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=96039#p96039</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95968#p95968" />
			<content type="html"><![CDATA[<p>У SetTimer&#039;ов время разное может быть? <br />Эти таймеры должны&nbsp; при совпадении 2х и более запущенных таймеров, должны работать одновременно и не прерывать друг друга?<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;скрипт</div><div class="fancy_spoiler"><div class="codebox"><pre><code>x:=1,   Time := [5,10,5,10,5,10,5,10,5] , Timer := []
loop % Time.MaxIndex()
    Timer.Insert(1)
settimer monitor,100
1::
2::
3::
4::
5::
6::
7::
8::
9::
x:=A_ThisHotkey
if (Timer[x] = 1)
    Timer[x] -= Time[x]
return

monitor:
Timer_list := &quot;&quot;
;% (h)?(h:=0)
loop % Time.MaxIndex()
    if (((Timer[A_Index] &lt; 1) and Timer[A_Index]++) ? &quot;&quot; : &quot;&quot;) (Timer[A_Index] = 0)
        h := A_Index
;if !h
;    return
loop % Time.MaxIndex()
    Timer_list .= (Timer_list? &quot;`n&quot; : &quot;&quot;) A_Index &quot;)`t`t&quot; Timer[A_Index]-1
tooltip % &quot;Таймеры:`n&quot; Timer_list &quot;`nпосл-й таймер)`t&quot; h</code></pre></div></div></div><p>monitor1_timer, monitor2_timer и т.д они все структурой отличаются друг от друга? если нет то можно все под один шаблон сделать ведь.</p>]]></content>
			<author>
				<name><![CDATA[yalanne]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32850</uri>
			</author>
			<updated>2015-07-24T08:23:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95968#p95968</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95959#p95959" />
			<content type="html"><![CDATA[<p>На одну и ту же метку 2 таймера не поставить - новое значение перезапишет старое.</p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2015-07-24T05:08:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95959#p95959</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95958#p95958" />
			<content type="html"><![CDATA[<p>А зачем 200?<br />Можно использовать одну:<br /></p><div class="codebox"><pre><code>label:
if
...
else if
...
else
...</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2015-07-24T01:17:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95958#p95958</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95956#p95956" />
			<content type="html"><![CDATA[<p>А если этих меток 200, Вы все 200 будете переписывать?</p><p>3)Нужно задать BoxMonitor%Loop_Index%_SetTimer в время SetTimer, как это сделать?<br /></p><div class="codebox"><pre><code>%BoxMonitor%Loop_Index%_SetTimer%</code></pre></div><p>В<br /></p><div class="codebox"><pre><code>SetTimer, monitor%Loop_Index%_timer, %BoxMonitor1_SetTimer%</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Странникх]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30605</uri>
			</author>
			<updated>2015-07-23T23:58:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95956#p95956</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95943#p95943" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>1::
x := 1
Return

2::
x := 2
Return

3::
Gosub,Label%x%
Return

Label1:
MsgBox, 1
return
Label2:
MsgBox, 2
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2015-07-23T18:34:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95943#p95943</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95942#p95942" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Тоже самое:<br /></p><div class="codebox"><pre><code>1::
x := 2
Return

2::
x := 1
Return

3::
Gosub,Label
Return

Label:
if x = 1
MsgBox, 1
if x = 2
MsgBox, 2
Return</code></pre></div></blockquote></div><p>Как тогда задать и запустить метку со значением переменной?</p><div class="codebox"><pre><code>Label%Var%:</code></pre></div><p>По второму вопросу: решил созданием переменной в виде счетчика цикла</p>]]></content>
			<author>
				<name><![CDATA[Странникх]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30605</uri>
			</author>
			<updated>2015-07-23T17:26:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95942#p95942</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95928#p95928" />
			<content type="html"><![CDATA[<p>Ничо не понял! Объясните нормально что Вам нужно.</p>]]></content>
			<author>
				<name><![CDATA[Доктор ТуамОсес]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31413</uri>
			</author>
			<updated>2015-07-23T16:27:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95928#p95928</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Динамическая метка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=95920#p95920" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>С первым вопросом методом тыка разобрался:</p></blockquote></div><p>Тоже самое:<br /></p><div class="codebox"><pre><code>1::
x := 2
Return

2::
x := 1
Return

3::
Gosub,Label
Return

Label:
if x = 1
MsgBox, 1
if x = 2
MsgBox, 2
Return
</code></pre></div><div class="quotebox"><blockquote><p>Можно ли изменять A_Index в Loop?</p></blockquote></div><p>Нельзя. Можно сохранять в переменную и делать с ней все что угодно.</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2015-07-23T14:44:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=95920#p95920</id>
		</entry>
</feed>
