<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Завершение процесса после закрытия окна]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=18392</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18392&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Завершение процесса после закрытия окна».]]></description>
		<lastBuildDate>Fri, 07 Mar 2025 21:46:12 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162064#p162064</link>
			<description><![CDATA[<p>Уважаемый <strong>teadrinker</strong> Спасибо большое всё работает.</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Fri, 07 Mar 2025 21:46:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162064#p162064</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162063#p162063</link>
			<description><![CDATA[<p>Попробуйте так:<br /></p><div class="codebox"><pre><code>#Requires AutoHotkey v2
Persistent

wndClass := &#039;class1|class2&#039;

EVENT_OBJECT_HIDE := 0x8003
Hook := WinEventHook(EVENT_OBJECT_HIDE, EVENT_OBJECT_HIDE, HookProc, &#039;F&#039;)

HookProc(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime) {
    static OBJID_WINDOW := 0
    try if (idObject = OBJID_WINDOW &amp;&amp; WinGetClass(hwnd) ~= wndClass) {
        ProcessClose WinGetPID(hwnd)
    }
}

class WinEventHook
{
    __New(eventMin, eventMax, hookProc, options := &#039;&#039;, idProcess := 0, idThread := 0, dwFlags := 0) {
        this.pCallback := CallbackCreate(hookProc, options, 7)
        this.hHook := DllCall(&#039;SetWinEventHook&#039;, &#039;UInt&#039;, eventMin, &#039;UInt&#039;, eventMax, &#039;Ptr&#039;, 0, &#039;Ptr&#039;, this.pCallback
                                               , &#039;UInt&#039;, idProcess, &#039;UInt&#039;, idThread, &#039;UInt&#039;, dwFlags, &#039;Ptr&#039;)
    }
    __Delete() {
        DllCall(&#039;UnhookWinEvent&#039;, &#039;Ptr&#039;, this.hHook)
        CallbackFree(this.pCallback)
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 07 Mar 2025 20:52:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162063#p162063</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162062#p162062</link>
			<description><![CDATA[<p>Большое спасибо <strong>teadrinker</strong> всё работает. Подскажите как дописать несколько окон в &quot;wndClass&quot;.<br /></p><div class="codebox"><pre><code>wndClass := &#039;GameCenter.TMainForm&#039; or &#039;Qt51515QWindowIcon&#039;</code></pre></div><p>Так не работает.</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Fri, 07 Mar 2025 20:39:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162062#p162062</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162061#p162061</link>
			<description><![CDATA[<div class="codebox"><pre><code>#Requires AutoHotkey v2
Persistent

wndClass := &#039;µTorrent4823DF041B09&#039; ; класс окна, закрытие которого отслеживаем

EVENT_OBJECT_HIDE := 0x8003
Hook := WinEventHook(EVENT_OBJECT_HIDE, EVENT_OBJECT_HIDE, HookProc, &#039;F&#039;)

HookProc(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime) {
    static OBJID_WINDOW := 0
    try if (idObject = OBJID_WINDOW &amp;&amp; wndClass = WinGetClass(hwnd)) {
        ProcessClose WinGetPID(hwnd)
    }
}

class WinEventHook
{
    __New(eventMin, eventMax, hookProc, options := &#039;&#039;, idProcess := 0, idThread := 0, dwFlags := 0) {
        this.pCallback := CallbackCreate(hookProc, options, 7)
        this.hHook := DllCall(&#039;SetWinEventHook&#039;, &#039;UInt&#039;, eventMin, &#039;UInt&#039;, eventMax, &#039;Ptr&#039;, 0, &#039;Ptr&#039;, this.pCallback
                                               , &#039;UInt&#039;, idProcess, &#039;UInt&#039;, idThread, &#039;UInt&#039;, dwFlags, &#039;Ptr&#039;)
    }
    __Delete() {
        DllCall(&#039;UnhookWinEvent&#039;, &#039;Ptr&#039;, this.hHook)
        CallbackFree(this.pCallback)
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 07 Mar 2025 18:58:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162061#p162061</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162060#p162060</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Если хотите, могу пример на v2 написать, на v1 уже не хочется.</p></blockquote></div><p> Если можно напишите.</p>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Fri, 07 Mar 2025 16:03:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162060#p162060</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162059#p162059</link>
			<description><![CDATA[<p>Если хотите, могу пример на v2 написать, на v1 уже не хочется.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 07 Mar 2025 15:36:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162059#p162059</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Завершение процесса после закрытия окна]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=162058#p162058</link>
			<description><![CDATA[<p>Доброго времени суток . Подскажите как завершить процесс после закрытия окна . Есть приложения у которых нажимаешь красный крестик а оно висит в трэе.<br /></p><div class="codebox"><pre><code>
WinWait, ahk_class GameCenter.TMainForm
WinWaitClose
{
WinGet, ahk_pid, PID, A
WinGet, active_pid, PID, A
WinGetTitle, active_title, A
}
Process, Close, %active_pid%
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Fri, 07 Mar 2025 13:46:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=162058#p162058</guid>
		</item>
	</channel>
</rss>
