<?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=6558&amp;type=atom" />
	<updated>2021-04-16T16:19:20Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6558</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147376#p147376" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Знаками процента можно обрамлять только одну переменную. Но ещё можно так записать:<br /></p><div class="codebox"><pre><code>For Process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ExecutablePath LIKE &#039;%E:\\%&#039;&quot;)
   WinClose, % &quot;ahk_pid&quot; . Process.ProcessId</code></pre></div></blockquote></div><p>Попробовал. Ошибку не выдаёт, но и программы не закрывает.</p>]]></content>
			<author>
				<name><![CDATA[alex22]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41647</uri>
			</author>
			<updated>2021-04-16T16:19:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147376#p147376</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147355#p147355" />
			<content type="html"><![CDATA[<p>Знаками процента можно обрамлять только одну переменную. Но ещё можно так записать:<br /></p><div class="codebox"><pre><code>For Process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ExecutablePath LIKE &#039;%E:\\%&#039;&quot;)
   WinClose, % &quot;ahk_pid&quot; . Process.ProcessId</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-15T22:01:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147355#p147355</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147353#p147353" />
			<content type="html"><![CDATA[<p>По-другому не умею. Пробовал<br /></p><div class="codebox"><pre><code>For Process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ExecutablePath LIKE &#039;%E:\\%&#039;&quot;)
   WinClose, ahk_pid %Process.ProcessId%</code></pre></div><p>Получил ошибку.</p>]]></content>
			<author>
				<name><![CDATA[alex22]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41647</uri>
			</author>
			<updated>2021-04-15T18:56:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147353#p147353</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147338#p147338" />
			<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>2021-04-14T19:31:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147338#p147338</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147335#p147335" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>А зачем вы все процессы каждый раз заново в одну переменную записываете? И зачем там (1) ?</p></blockquote></div><p>Зачем (1) понятия не имею, так в образце было. Процессы в переменную пишу чтобы в что в WinClose передать, как по другому?</p>]]></content>
			<author>
				<name><![CDATA[alex22]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41647</uri>
			</author>
			<updated>2021-04-14T16:53:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147335#p147335</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147332#p147332" />
			<content type="html"><![CDATA[<p>А зачем вы все процессы каждый раз заново в одну переменную записываете? И зачем там (1) ?<br />Но в любом случае придётся ждать, пока очередное окно закроется, если не примерить как-то многопоточность, ищите на форуме.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-14T15:19:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147332#p147332</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147327#p147327" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Спасибо, теперь заработало, хотя и не так, как хотелось бы: если Process.Terminate завершает ВСЕ найденные в цикле for подходящие процессы, то в переменную записывается PID только верхнего процесса, поэтому пока не будет закрыт текущий процесс, следующий команду на закрытие не получит. Даже на небольших прогах, которые запустил для эксперимента, долго вышло, а в реальной работе предвижу секунд 20-30. Или все же придется убивать особенно долго завершающиеся процессы, чего не хотелось бы.<br /></p><div class="codebox"><pre><code>DetectHiddenWindows, on
Loop
{
NN = 0
For Process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ExecutablePath LIKE &#039;%E:\\%&#039;&quot;)
   NN := Process.ProcessId(1)
if NN = 0
   break
WinClose, ahk_pid %NN%
;WinWaitClose,,, 5
;if ErrorLevel
;WinKill, ahk_pid %NN%
;Process, Close,%NN%
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alex22]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41647</uri>
			</author>
			<updated>2021-04-14T12:59:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147327#p147327</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147324#p147324" />
			<content type="html"><![CDATA[<p>Для закрытия окна пользуюсь этой функцией:<br /></p><div class="codebox"><pre><code>CorrectCloseProcess(WinTitle)
{
  loop,50
  {
    a++
    t:=a_tickcount
    SendMessage,WM_QUERYENDSESSION:=0x11,0,1,,% WinTitle
    d:=a_tickcount-t
    if (d&gt;100)
      return -1
    b:=ErrorLevel
    SendMessage,WM_CLOSE:=0x10,,,,% WinTitle
    if (b=&quot;FAIL&quot;)
      return a
    sleep,10
  }
}</code></pre></div><p>Возможно есть варианты лучше.</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2021-04-14T12:27:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147324#p147324</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147321#p147321" />
			<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>2021-04-14T10:48:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147321#p147321</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147319#p147319" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />И как им воспользоваться?<br />Так не работает <br /></p><div class="codebox"><pre><code>For Process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE ExecutablePath LIKE &#039;%E:\%&#039;&quot;)
   NN := Process.ProcessId</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alex22]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41647</uri>
			</author>
			<updated>2021-04-14T10:30:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147319#p147319</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147317#p147317" />
			<content type="html"><![CDATA[<p>PID&nbsp; — свойство ProcessId.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-14T10:22:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147317#p147317</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147315#p147315" />
			<content type="html"><![CDATA[<p>Апну тему, потому что нужно почти то же самое - закрывать приложения, запущенные со съемного диска.<br /></p><div class="quotebox"><cite>Александр_ пишет:</cite><blockquote><p>Только перебором всех процессов. Если нужен максимально короткий код, то через WMI:<br /></p><div class="codebox"><pre><code>For Process in ComObjGet(&quot;winmgmts:&quot;).ExecQuery(&quot;Select * from Win32_Process WHERE CommandLine LIKE &#039;%calc%&#039;&quot;)
   Process.Terminate(1)</code></pre></div><p>Убьёт все процессы, содержащие в командной строке(включая и имя файла) подстроку &quot;calc&quot;.</p></blockquote></div><p>Код отличный, но нет ли возможности вместо terminate попытаться сначала закрыть окно, (пробовал заменить на CloseMainWindow - не работает). Или как-то добыть из цикла PID процессов для закрытия через WinClose.</p>]]></content>
			<author>
				<name><![CDATA[alex22]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41647</uri>
			</author>
			<updated>2021-04-14T10:14:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147315#p147315</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54716#p54716" />
			<content type="html"><![CDATA[<p>Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2011-12-17T14:04:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54716#p54716</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54715#p54715" />
			<content type="html"><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394552(v=VS.85).aspx">WMI and SQL</a> и связанные темы.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-12-17T14:02:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54715#p54715</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершить скрипт, содержащий определённый параметр ком. строки]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54706#p54706" />
			<content type="html"><![CDATA[<p>Позвольте околопредметный вопрос <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Есть ли источник где можно ознакомится с синтаксисом WQL? Желательно с примерами построения запросов и описанием доступной функциональности.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2011-12-17T10:01:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54706#p54706</id>
		</entry>
</feed>
