<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=8801&amp;type=atom" />
	<updated>2013-10-24T05:51:12Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=8801</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76387#p76387" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
#SingleInstance off
OnMessage( DllCall(&quot;RegisterWindowMessage&quot;, &quot;Str&quot;, &quot;WM_HIGHLANDER&quot;), &quot;Receive_WM_HIGHLANDER&quot;)
OnExit Exit
Param = %1%
IsFunc(Param) ? %Param%() : (CloseAllSame(), 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()  { 
    Menu, Tray, NoIcon 
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; DllCall(&quot;GetCurrentProcessId&quot;),111,222 
} 

CloseAllSame()   {
    WM_HIGHLANDER := DllCall(&quot;RegisterWindowMessage&quot;, &quot;Str&quot;, &quot;WM_HIGHLANDER&quot;)
    PostMessage, WM_HIGHLANDER, 0, A_ScriptHWND,, ahk_id 0xFFFF 
 
}

Receive_WM_HIGHLANDER(wParam, lParam)   {
    If (lParam &lt;&gt; A_ScriptHWND)
        ExitApp
    return true
}

Exit:  
    If A_ExitReason = Menu
        CloseAllSame() 
    ExitApp
    
~Esc:: ExitApp
</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?pid=84612#p84612">Вот получше решение.</a></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-10-24T05:51:12Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76387#p76387</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76382#p76382" />
			<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 
   ; содержимое odin.ahk
   loop,100
      {
      ToolTip, % A_MSec,700,700,1
      sleep, 777
      }
}

proc2()  { 
    ; содержимое dva.ahk
    loop,10000
      {
      ToolTip, % A_MSec,700,730,2      
      }
} </code></pre></div><p>&nbsp; &nbsp;Отлично работает, независимо друг от друга. Два одноименный процесса.&nbsp; Спасибо!<br />&nbsp; &nbsp;Осталось разобраться с иконками и управлением через трей. Пока только один процесс&nbsp; убивается через &quot;Exit&quot;.</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-10-23T23:35:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76382#p76382</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76369#p76369" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><p><a href="http://forum.script-coding.com/viewtopic.php?id=8584">This</a></p></blockquote></div><p><a href="http://www.autohotkey.com/board/topic/56141-ahkv2-dynarun-run-autohotkey-process-dynamically/">And that</a></p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2013-10-23T15:26:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76369#p76369</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76368#p76368" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Next пишет:</cite><blockquote><p>Что-то я пока не понял как должен работать код из 11. Из *.ahk запускается два скрипта, а после компиляции и запуска *.exe, в диспетчере только один процесс видно, да и тот потом исчезает.</p></blockquote></div><p>Если так смущает иконка в трее, можно для второй и последующих запущенных &quot;копий&quot; скрыть иконку<br /></p><div class="codebox"><pre><code>proc2()
{
   Menu, Tray, NoIcon 
   ; ... dva.ahk
}</code></pre></div><p>После компиляции скрипт из #11 работает так же точно, пока не закрыт ни один из MsgBox, будут оба процесса.</p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2013-10-23T15:19:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76368#p76368</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76366#p76366" />
			<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 
    ; содержимое odin.ahk
}

proc2()  { 
    ; содержимое dva.ahk
} 
 
 
; /|\ /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\ 

</code></pre></div><br /><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Если не понятно с функциями, можно также с метками:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>
#SingleInstance off
 
Param = %1% 
GoTo % IsLabel(Param) ? Param : &quot;odin_ahk&quot;

; \|/ \|/  \|/  \|/  \|/  \|/  \|/  \|/  \|/  \|/  \|/  \|/  \|/ 


odin_ahk:
    Run, &quot;%A_ScriptFullPath%&quot; dva_ahk
    MsgBox содержимое odin.ahk
    Return

dva_ahk:
    MsgBox содержимое dva.ahk
    Return
 
 
; /|\ /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\  /|\
</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-10-23T13:18:17Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76366#p76366</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76365#p76365" />
			<content type="html"><![CDATA[<p>Я о &quot;своих&quot; двух речь веду. Ну вот создал я два скрипта. odin.ahk и dva.ahk. А потом беру один из ваших вариантов ... и?</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-10-23T13:11:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76365#p76365</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76364#p76364" />
			<content type="html"><![CDATA[<p>Это полный код скрипта. Их не надо объединять, это просто три варианта одного и того же.<br />Запускаешь один любой из них, и делаешь выводы.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-10-23T12:45:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76364#p76364</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76363#p76363" />
			<content type="html"><![CDATA[<p>Где должен располагаться код двух вышеупомянутых скриптов?</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-10-23T12:32:55Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76363#p76363</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76358#p76358" />
			<content type="html"><![CDATA[<p><strong>Next</strong><br />Не понял вопрос.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-10-23T09:21:25Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76358#p76358</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76354#p76354" />
			<content type="html"><![CDATA[<p><a href="mailto:А лучше так:">А лучше так:</a><br />&nbsp; Я правильно понимаю, что это &quot;стартер&quot; для двух других скриптов?</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-10-22T22:35:04Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76354#p76354</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76349#p76349" />
			<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()  { 
    loop
        ToolTip % A_ThisFunc &quot;`n&quot; A_TickCount &quot;`nProcessId = &quot; DllCall(&quot;GetCurrentProcessId&quot;),111,333
}

~Esc:: 
    ExitApp

</code></pre></div><br /><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Да и ещё при старте без параметра, надо наверное закрыть остальные:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>

#SingleInstance off

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

proc1()  { 
    CloseAllSame()
    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
}

CloseAllSame()  {   
    CurPID := DllCall(&quot;GetCurrentProcessId&quot;)
    WinGet, List, List, ahk_exe %A_ScriptFullPath%   ;  только для компилированного
    Loop % List
    {
        WinGet, PID, PID, % &quot;ahk_id &quot; List%A_Index%
        If (PID != CurPID) 
            Process, Close, %PID%
    }
}

~Esc:: 
    ExitApp

</code></pre></div></div></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;А лучше так:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>

#SingleInstance off

OnMessage( DllCall(&quot;RegisterWindowMessage&quot;, &quot;Str&quot;, &quot;WM_HIGHLANDER&quot;), &quot;Receive_WM_HIGHLANDER&quot;)
Param = %1%
IsFunc(Param) ? %Param%() : (CloseAllSame(), 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
} 

CloseAllSame()   {
    WM_HIGHLANDER := DllCall(&quot;RegisterWindowMessage&quot;, &quot;Str&quot;, &quot;WM_HIGHLANDER&quot;)
    PostMessage, WM_HIGHLANDER, 0, A_ScriptHWND,, ahk_id 0xFFFF 
}

Receive_WM_HIGHLANDER(wParam, lParam)   {
    If (lParam &lt;&gt; A_ScriptHWND)
        ExitApp
    return true
}

~Esc:: 
    ExitApp

</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-10-22T19:23:33Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76349#p76349</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76347#p76347" />
			<content type="html"><![CDATA[<p>Что-то я пока не понял как должен работать код из 11. Из *.ahk запускается два скрипта, а после компиляции и запуска *.exe, в диспетчере только один процесс видно, да и тот потом исчезает.</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-10-22T19:15:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76347#p76347</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76345#p76345" />
			<content type="html"><![CDATA[<p>Может запускать разные подпрограммы, в зависимости от параметров командной строки? Тогда число различных процессов, которые можно запустить из одного скомпилированного скрипта неограничено.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2013-10-22T18:26:33Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76345#p76345</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76344#p76344" />
			<content type="html"><![CDATA[<p>В посте #9 указана подходящая методика<br /></p><div class="codebox"><pre><code>#SingleInstance off
if 1 = twice
   proc2()
else {
   Run, %A_ScriptFullPath% twice
   proc1()
}
Return

proc1()
{
   MsgBox Первый!
}

proc2()
{
   MsgBox Второй!
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2013-10-22T18:19:16Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76344#p76344</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : Два процесса в из одного файла?]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=76343#p76343" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ypppu пишет:</cite><blockquote><p>Нужно из одного файла запустить два независимых разных процесса или два независимых одинаковых процесса?</p></blockquote></div><p>&nbsp; Разных.</p>]]></content>
			<author>
				<name><![CDATA[Next]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=28517</uri>
			</author>
			<updated>2013-10-22T17:50:06Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=76343#p76343</id>
		</entry>
</feed>
