<?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=9782&amp;type=atom" />
	<updated>2014-07-09T19:11:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9782</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84657#p84657" />
			<content type="html"><![CDATA[<p>Спасибо еще раз)</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-09T19:11:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84657#p84657</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84656#p84656" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>        OnExit
        ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-07-09T18:27:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84656#p84656</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84655#p84655" />
			<content type="html"><![CDATA[<p>Хм...я только заметил что если где-то написать exitapp то закрывает все процессы. Дело в том что у меня некоторые процессы закрываются после выполнения определенных действий, а остальные работают. Можно как-то сделать что бы если закрывать через трей то закрываются все процессы или если нажать например F2, а если написать в процессе exitapp то закрывается только этот процесс, а другие не трогает?</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-09T18:18:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84655#p84655</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84638#p84638" />
			<content type="html"><![CDATA[<p>Спасибо. Это даже лучше. Да у меня больше чем 2-3 процесса.</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-08T22:27:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84638#p84638</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84612#p84612" />
			<content type="html"><![CDATA[<p>Но это только для двух скриптов сработает.<br /><strong>Dworkin</strong> вообще в <a href="http://forum.script-coding.com/viewtopic.php?pid=76349#p76349">той теме</a> откуда этот код, есть решения вашего вопроса.<br />Если предположить, что скриптов может быть и больше 2, а также что закрытие любого из них, закрывает все остальные - это удобно, а перезапуск любого из них, перезапускает все остальные, то можно немного доработать одно из тех решений:<br /></p><div class="codebox"><pre><code>
#SingleInstance Off
WM_CloseMyScript := DllCall(&quot;RegisterWindowMessage&quot;, &quot;Str&quot;, &quot;CloseAHKScripts&quot;)
OnMessage(WM_CloseMyScript, &quot;WM_CloseMyScript&quot;)
OnExit, CloseAll
Param = %1%
If Param =
    PostMessage, WM_CloseMyScript, 0, A_ScriptHWND,, ahk_id 0xFFFF
IsFunc(Param) ? %Param%() : proc1() 
Return
 
proc1()  {  
    Run, %A_ScriptFullPath% proc2  
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; DllCall(&quot;GetCurrentProcessId&quot;),111,111
}

proc2()  {
    Run, %A_ScriptFullPath% proc3
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; DllCall(&quot;GetCurrentProcessId&quot;),111,222
}

proc3()  { 
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; DllCall(&quot;GetCurrentProcessId&quot;),111,333
}  


WM_CloseMyScript(wParam, lParam)   { 
    If (lParam != A_ScriptHWND)  {
        OnExit
        ExitApp
    }
    return true
}

F2::
CloseAll:
    PostMessage, WM_CloseMyScript, 0, A_ScriptHWND,, ahk_id 0xFFFF
    ExitApp
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-07-08T05:59:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84612#p84612</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84611#p84611" />
			<content type="html"><![CDATA[<p>Спасибо</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-08T05:38:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84611#p84611</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84610#p84610" />
			<content type="html"><![CDATA[<p>Это не потоки, а именно разные процессы.<br /></p><div class="codebox"><pre><code>#SingleInstance off
global ChildPid
Param = %1%
IsFunc(Param) ? %Param%() : proc1() 
Return


proc1()  {  
    Run, %A_ScriptFullPath% proc2,,, ChildPid
    Hotkey, F2, CloseAll, On
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; DllCall(&quot;GetCurrentProcessId&quot;),111,111
}

proc2()  {
    OnMessage(DllCall(&quot;RegisterWindowMessage&quot;, Str, &quot;CloseScript&quot;), &quot;CloseScript&quot;)
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; DllCall(&quot;GetCurrentProcessId&quot;),111,222
}

CloseScript()
{
    ExitApp
}

CloseAll:
DetectHiddenWindows, On
PostMessage, DllCall(&quot;RegisterWindowMessage&quot;, Str, &quot;CloseScript&quot;),,,, ahk_pid %ChildPid%
exitapp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-07-07T22:07:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84610#p84610</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: одновременно закрыть несколько потоков]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=84609#p84609" />
			<content type="html"><![CDATA[<p>Здрасте. Вот код:<br /></p><div class="codebox"><pre><code>#SingleInstance off

Param = %1%
IsFunc(Param) ? %Param%() : proc1() 
Return


proc1()  {  

    Run, %A_ScriptFullPath% proc2 
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; 

DllCall(&quot;GetCurrentProcessId&quot;),111,111
}

proc2()  {

    Run, %A_ScriptFullPath% proc3
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; 

DllCall(&quot;GetCurrentProcessId&quot;),111,222
}

proc3()  {
Hotkey, F2, ExitAll ; закрывает все сразу
}

ExitAll:
exitapp
return</code></pre></div><p>Если нажимать кнопку F2 то закрывается всего один процесс(поток). Скажите пожалуйста как сделать что бы можно было закрыть сразу все процессы(потоки)?</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2014-07-07T21:30:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=84609#p84609</id>
		</entry>
</feed>
