<?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=12251</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12251&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Закрыть окно программы которое сворачивается в трей при закрытии».]]></description>
		<lastBuildDate>Thu, 29 Dec 2016 02:09:18 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110392#p110392</link>
			<description><![CDATA[<p>Всем огромное спасибо за участие. Подошёл скрипт от <strong>teadrinker</strong> , вам отдельное спасибо .<br />Блин и как же я сам не догадался , всё гениальное просто.<br /></p><div class="codebox"><pre><code>WinWaitClose</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Thu, 29 Dec 2016 02:09:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110392#p110392</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110391#p110391</link>
			<description><![CDATA[<p>Если открытых приложений и процессов может быть одновременно несколько, по типу как у блокнота - тогда этот вариант может не подойти.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Thu, 29 Dec 2016 02:08:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110391#p110391</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110390#p110390</link>
			<description><![CDATA[<p>А, я не понял о чём ты, тогда да, опечатка. Но ещё логичнее так будет:<br /></p><div class="codebox"><pre><code>ExePath := &quot;OscarEditor.exe&quot;  ; здесь прописать полный путь к исполнимому файлу

Run, % ExePath
WinWait, OscareditorForm ahk_class TMainForm
WinWaitClose
Process, Close, OscarEditor.exe</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 29 Dec 2016 01:54:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110390#p110390</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110389#p110389</link>
			<description><![CDATA[<p>Как же он сработает, когда хендл у окна будет другой?<br /></p><div class="quotebox"><blockquote><p>After the Run command retrieves a PID, any windows to be created by the process might not exist yet. To wait for at least one window to be created, use WinWait <strong>ahk_pid</strong> %OutputVarPID%.</p></blockquote></div><p>А у тебя:<br /></p><div class="quotebox"><blockquote><p>WinWait, <strong>ahk_id</strong> %PID%</p></blockquote></div><p><a href="https://autohotkey.com/docs/commands/Run.htm">https://autohotkey.com/docs/commands/Run.htm</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Thu, 29 Dec 2016 01:48:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110389#p110389</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110388#p110388</link>
			<description><![CDATA[<p>Ну да, твой вариант логичнее, но мой сработает тоже, ошибки нет.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 29 Dec 2016 01:44:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110388#p110388</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110387#p110387</link>
			<description><![CDATA[<p>Может, но у тебя стоит ожидание хендла:<br /></p><div class="codebox"><pre><code>WinWait, ahk_id %PID%</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Thu, 29 Dec 2016 01:41:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110387#p110387</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110386#p110386</link>
			<description><![CDATA[<p>Почему ошибка? Там может быть название процесса.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 29 Dec 2016 01:37:49 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110386#p110386</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110385#p110385</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, у тебя ошибка. Правильно так:<br /></p><div class="codebox"><pre><code>ExePath := &quot;OscarEditor.exe&quot;  ; здесь прописать полный путь к исполнимому файлу

Run, % ExePath,,, PID
WinWait, ahk_pid %PID%
WinWaitClose
Process, Close, %PID%</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Thu, 29 Dec 2016 01:34:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110385#p110385</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110384#p110384</link>
			<description><![CDATA[<p>Можно так попробовать. Запускайте программу таким скриптом:<br /></p><div class="codebox"><pre><code>ExePath := &quot;OscarEditor.exe&quot;  ; здесь прописать полный путь к исполнимому файлу

Run, % ExePath,,, PID
WinWait, ahk_id %PID%
WinWaitClose
Process, Close, OscarEditor.exe</code></pre></div><p>При закрытии окна процесс должен завершиться, но нужно иметь в виду, что без сохранения данных.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 28 Dec 2016 22:30:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110384#p110384</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110383#p110383</link>
			<description><![CDATA[<div class="codebox"><pre><code>#IfWinActive OscareditorForm
LButton::
Click Down
IfWinNotActive OscareditorForm
{
   KeyWait LButton
   Click Up
}
return

LButton Up::
CoordMode, Mouse, Screen
MouseGetPos, x, y
SendMessage, 0x84,, (x &amp; 0xFFFF) | (y &amp; 0xFFFF) &lt;&lt; 16  ; WM_NCHITTEST
if (ErrorLevel = 20) ; close button
{
   WinGet, pid, pid, A
   Process, Close, %pid%
   NoTrayOrphans()     ; очистить трей от иконок закрытых приложений
}
Click Up
return
#IfWinActive


NoTrayOrphans()
{
    TrayInfo := TrayIcons(&quot;ahk_class Shell_TrayWnd&quot;, &quot;ToolbarWindow32&quot; . GetTrayBar())  
        . TrayIcons(&quot;ahk_class NotifyIconOverflowWindow&quot;, &quot;ToolbarWindow321&quot;)
 
    Loop, Parse, TrayInfo, `n
    {  
        PID := StrX(A_Loopfield, &quot;| PID: &quot;, &quot; |&quot;) 
        If !PID
            RemoveTrayIcon(StrX(A_Loopfield, &quot;| hWnd: &quot;, &quot; |&quot;), StrX(A_Loopfield, &quot;| uID: &quot;, &quot; |&quot;))   
    }
}

TrayIcons(traywindow, control)  
{
    DetectHiddenWindows, On
    WinGet, pidTaskbar, PID, %traywindow%
    hProc := DllCall(&quot;OpenProcess&quot;, &quot;Uint&quot;, 0x38, &quot;int&quot;, 0, &quot;Uint&quot;, pidTaskbar)
    pProc := DllCall(&quot;VirtualAllocEx&quot;, &quot;Uint&quot;, hProc, &quot;Uint&quot;, 0, &quot;Uint&quot;, 32, &quot;Uint&quot;, 0x1000, &quot;Uint&quot;, 0x4)
    SendMessage, 0x418, 0, 0, %control%, %traywindow%
    Loop, %ErrorLevel%
    {
        SendMessage, 0x417, A_Index - 1, pProc, %control%, %traywindow%
        VarSetCapacity(btn, 32, 0), VarSetCapacity(nfo, 32, 0)
        DllCall(&quot;ReadProcessMemory&quot;, &quot;Uint&quot;, hProc, &quot;Uint&quot;, pProc, &quot;Uint&quot;, &amp;btn, &quot;Uint&quot;, 32, &quot;Uint&quot;, 0)
        iBitmap := NumGet(btn, 0)
        idn := NumGet(btn, 4)
        Statyle := NumGet(btn, 8)
        If dwData := NumGet(btn, 12)
            iString := NumGet(btn, 16)
        Else
        {
            dwData := NumGet(btn, 16, &quot;int64&quot;)
            iString := NumGet(btn, 24, &quot;int64&quot;)
        }
        DllCall(&quot;ReadProcessMemory&quot;, &quot;Uint&quot;, hProc, &quot;Uint&quot;, dwData, &quot;Uint&quot;, &amp;nfo, &quot;Uint&quot;, 32, &quot;Uint&quot;, 0)
        If NumGet(btn,12)
        {
            hWnd := NumGet(nfo, 0)
            uID := NumGet(nfo, 4)
            nMsg := NumGet(nfo, 8)
            hIcon := NumGet(nfo, 20)
        }
        Else
        {
            hWnd := NumGet(nfo, 0, &quot;int64&quot;)
            uID := NumGet(nfo, 8)
            nMsg := NumGet(nfo, 12)
            hIcon := NumGet(nfo, 24)
        }
        WinGet, pid, PID, ahk_id %hWnd%
        WinGet, sProcess, ProcessName, ahk_id %hWnd%
        WinGetClass, sClass, ahk_id %hWnd% 
        VarSetCapacity(sTooltip, 128)
        VarSetCapacity(wTooltip, 128*2)
        DllCall(&quot;ReadProcessMemory&quot;, &quot;Uint&quot;, hProc, &quot;Uint&quot;, iString, &quot;Uint&quot;, &amp;wTooltip, &quot;Uint&quot;, 128*2, &quot;Uint&quot;, 0)
        DllCall(&quot;WideCharToMultiByte&quot;, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0, &quot;str&quot;, wTooltip, &quot;int&quot;, -1, &quot;str&quot;, sTooltip, &quot;int&quot;, 128, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0)
        sTrayIcons .= &quot;| Pid: &quot; pid &quot; | uID: &quot; uID &quot; | hWnd: &quot; hWnd &quot; |`n&quot; 
    }
    DllCall(&quot;VirtualFreeEx&quot;, &quot;Uint&quot;, hProc, &quot;Uint&quot;, pProc, &quot;Uint&quot;, 0, &quot;Uint&quot;, 0x8000)
    DllCall(&quot;CloseHandle&quot;, &quot;Uint&quot;, hProc)
    Return sTrayIcons
}

GetTrayBar()
{
    ControlGet, hParent, hWnd,, TrayNotifyWnd1, ahk_class Shell_TrayWnd
    ControlGet, hChild, hWnd,, ToolbarWindow321, ahk_id %hParent%
    Loop
    {
        ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
        If (hWnd == hChild)
            idxTB := A_Index
        If !hWnd || (hWnd == hChild)
            Break
    }
    Return idxTB
}

StrX(H, BS = &quot;&quot;, ES = &quot;&quot;, Tr = 1, ByRef OS = 1)
{
    Return (SP := InStr(H, BS, 0, OS)) &amp;&amp; (L := InStr(H, ES, 0, SP + StrLen(BS))) &amp;&amp; (OS := L + StrLen(ES)) ? SubStr(H, SP := Tr ? SP + StrLen(BS) : SP, (Tr ? L : L + StrLen(ES)) -SP) : &quot;&quot;
}

RemoveTrayIcon(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
{
    NumPut(VarSetCapacity(ni,444,0), ni)
    NumPut(hWnd, ni, 4)
    NumPut(uID, ni, 8)
    NumPut(1|2|4, ni, 12)
    NumPut(nMsg, ni, 16)
    NumPut(hIcon, ni, 20)
    Return DllCall(&quot;shell32\Shell_NotifyIconA&quot;, &quot;Uint&quot;, nRemove, &quot;Uint&quot;, &amp;ni)
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 28 Dec 2016 21:37:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110383#p110383</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110382#p110382</link>
			<description><![CDATA[<p>Оба скрипта не работают . Я не понимаю как можно сделать ожидание нажатия на кнопку (X) .<br />Если только при помощи команды.<br /></p><div class="codebox"><pre><code>MouseGetPos</code></pre></div><p>Но как я непойму ,попав на координаты кнопки внутри окна послдать нужную команду.<br /></p><div class="codebox"><pre><code>WinClose или Process, Close</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Wed, 28 Dec 2016 21:17:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110382#p110382</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110352#p110352</link>
			<description><![CDATA[<p>У меня так с блокнотом работает (при нажатии на крестик минимизирует окно):<br /></p><div class="codebox"><pre><code>#IfWinActive ahk_class Notepad
LButton::
Click Down
IfWinNotActive ahk_class Notepad
{
   KeyWait LButton
   Click Up
}
return

LButton Up::
CoordMode, Mouse, Screen
MouseGetPos, x, y
SendMessage, 0x84,, (x &amp; 0xFFFF) | (y &amp; 0xFFFF) &lt;&lt; 16  ; WM_NCHITTEST
if (ErrorLevel = 20) ; close button
   WinMinimize, A
Click Up
return
#IfWinActive</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Tue, 27 Dec 2016 19:23:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110352#p110352</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110318#p110318</link>
			<description><![CDATA[<div class="codebox"><pre><code>WinGet, hWnd, ID, ahk_class TMainForm ahk_exe OscarEditor.exe ; получаем хэндл OscarEditor
hSysMenu := DllCall( &quot;GetSystemMenu&quot;, &quot;Uint&quot;, hWnd, &quot;int&quot;, False ) ; получаем хэндл системного меню
DllCall( &quot;GetSystemMenu&quot;, &quot;Uint&quot;, hWnd, &quot;int&quot;, True ) ; восстанавливаем системное меню</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Tue, 27 Dec 2016 10:07:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110318#p110318</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110121#p110121</link>
			<description><![CDATA[<p>Ну я из из предоставленной темы ничего непонял. Вот даю папаметры приложения.</p><div class="codebox"><pre><code>
Title - OscareditorForm
Class - ahk_class TMainForm 
ProcessName - ahk_exe OscarEditor.exe
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Sat, 24 Dec 2016 23:09:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110121#p110121</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Закрыть окно программы которое сворачивается в трей при закрытии]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=110115#p110115</link>
			<description><![CDATA[<p>Есть <a href="http://forum.script-coding.com/viewtopic.php?id=363">такая тема </a>в Коллекции. В ней имеется код<br /></p><div class="codebox"><pre><code>DllCall( &quot;GetSystemMenu&quot;, &quot;Uint&quot;, hWnd, &quot;int&quot;, True ) ; восстанавливаем системное меню</code></pre></div><p>У меня есть программа, в которой изначально крестик не закрывает программу. Пробовал в ней восстановить системное меню - не помогло. Может быть у Вас получится.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Sat, 24 Dec 2016 18:42:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=110115#p110115</guid>
		</item>
	</channel>
</rss>
