<?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=18392&amp;type=atom" />
	<updated>2025-03-07T21:46:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=18392</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=162064#p162064" />
			<content type="html"><![CDATA[<p>Уважаемый <strong>teadrinker</strong> Спасибо большое всё работает.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2025-03-07T21:46:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=162064#p162064</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=162063#p162063" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2025-03-07T20:52:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=162063#p162063</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=162062#p162062" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2025-03-07T20:39:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=162062#p162062</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=162061#p162061" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2025-03-07T18:58:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=162061#p162061</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=162060#p162060" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Если хотите, могу пример на v2 написать, на v1 уже не хочется.</p></blockquote></div><p> Если можно напишите.</p>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2025-03-07T16:03:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=162060#p162060</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Завершение процесса после закрытия окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=162059#p162059" />
			<content type="html"><![CDATA[<p>Если хотите, могу пример на v2 написать, на v1 уже не хочется.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2025-03-07T15:36:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=162059#p162059</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Завершение процесса после закрытия окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=162058#p162058" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Ядрён]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30092</uri>
			</author>
			<updated>2025-03-07T13:46:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=162058#p162058</id>
		</entry>
</feed>
