<?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>http://forum.script-coding.com/viewtopic.php?id=9801</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=9801&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Двойная иконка в трее.».]]></description>
		<lastBuildDate>Sun, 13 Jul 2014 14:54:46 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Двойная иконка в трее.]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=84741#p84741</link>
			<description><![CDATA[<p>Например, так:<br /></p><div class="codebox"><pre><code>if hIcon := ExtractIcon(A_AhkPath, 2, 16)
   hAssociatedGui1 := AddTrayIcon(hIcon)  ; первая дополнительная иконка

if hIcon := ExtractIcon(&quot;Shell32.dll&quot;, 44, 16)
   hAssociatedGui2 := AddTrayIcon(hIcon)  ; вторая дополнительная иконка
OnExit, Exit

; если нужно меню для иконок
OnMessage(0x404, &quot;AHK_NOTIFYICON&quot;)
Menu, MyTrayMenu, Add, Завершение работы, CloseApp
Return

CloseApp:
   ExitApp

Exit:
   RemoveTrayIcon(hAssociatedGui1), RemoveTrayIcon(hAssociatedGui2)
   ExitApp

ExtractIcon(sFile, IconNumber, IconSize)
{
   coding := A_IsUnicode ? &quot;W&quot; : &quot;A&quot;

   SplitPath, sFile,,, ext
   (ext = &quot;ico&quot; &amp;&amp; IconNumber := 0)

   if PrivateExtractIcons := DllCall(&quot;GetProcAddress&quot;
                              , Ptr, DllCall(&quot;LoadLibrary&quot;, Str, &quot;User32&quot;, Ptr)
                              , AStr, &quot;PrivateExtractIcons&quot; . coding, Ptr)
   {
      Result := DllCall(PrivateExtractIcons, Str, sFile, Int, IconNumber-1
                  , Int, IconSize, Int, IconSize, PtrP, hIcon, UIntP, 0, UInt, 1, UInt, 0)
      if !Result
         MsgBox, 16,, % &quot;Не удалось извлечь иконку.`nОшибка &quot; A_LastError
      else if (Result = 0xFFFFFFFF || Result = -1)
         MsgBox, 16,, Файл &quot;%sFile%&quot; не найден!
   }

   else
   {
      if !DllCall(&quot;Shell32\ExtractIconEx&quot; . coding, Str, sFile, Int, IconNumber-1, PtrP, hIconLarge, PtrP, hIconSmall, UInt, 1)
      {
         MsgBox, 16,, % &quot;Не удалось извлечь иконку.`nОшибка &quot; A_LastError
         return
      }
      SysGet, SmallIconSize, % SM_CXSMICON := 49
      if (IconSize &lt;= SmallIconSize)
         DllCall(&quot;DestroyIcon&quot;, Ptr, hIconLarge), hIcon := hIconSmall
      else
         DllCall(&quot;DestroyIcon&quot;, Ptr, hIconSmall), hIcon := hIconLarge

      hIcon := DllCall(&quot;CopyImage&quot;, Ptr, hIcon, UInt, IMAGE_ICON := 1
         , Int, IconSize, Int, IconSize, UInt, LR_COPYRETURNORG := 0x4|LR_COPYDELETEORG := 0x8, Ptr)
   }

   Return hIcon
}

AddTrayIcon(hIcon)
{
   static NIF_MESSAGE := 1, NIF_ICON := 2, GuiNumber := 99
   
   VarSetCapacity(NOTIFYICONDATA, size := A_PtrSize = 8 ? 848 : A_IsUnicode? 828 : 444, 0)
   NumPut(size, NOTIFYICONDATA, &quot;UInt&quot;)
   Gui, % GuiNumber-- &quot;: +hwndhGui&quot;
   NumPut(hGui, NOTIFYICONDATA, A_PtrSize)
   NumPut(uID := 0x404, NOTIFYICONDATA, 2*A_PtrSize, &quot;UInt&quot;)
   NumPut(NIF_MESSAGE|NIF_ICON, NOTIFYICONDATA, 2*A_PtrSize + 4, &quot;UInt&quot;)
   NumPut(nMsg := 0x404, NOTIFYICONDATA, 2*A_PtrSize + 8, &quot;UInt&quot;)
   NumPut(hIcon, NOTIFYICONDATA, 3*A_PtrSize+8)
   
   DllCall(&quot;shell32\Shell_NotifyIcon&quot;, UInt, NIM_ADD := 0, Ptr, &amp;NOTIFYICONDATA)
   DllCall(&quot;DestroyIcon&quot;, Ptr, hIcon)
   Return hGui
}

RemoveTrayIcon(hWnd, uID=0x404)
{
   VarSetCapacity(NOTIFYICONDATA, size := A_PtrSize = 8 ? 848 : A_IsUnicode? 828 : 444, 0)
   NumPut(size, NOTIFYICONDATA, &quot;UInt&quot;)
   NumPut(hWnd, NOTIFYICONDATA, A_PtrSize)
   NumPut(uID, NOTIFYICONDATA, 2*A_PtrSize, &quot;UInt&quot;)
   DllCall(&quot;shell32\Shell_NotifyIcon&quot;, &quot;UInt&quot;, NIM_DELETE := 2, Ptr, &amp;NOTIFYICONDATA)
   Return
}

AHK_NOTIFYICON(wp, lp, msg, hwnd)   ; wp — uID, lp — Message
{
   global hAssociatedGui1, hAssociatedGui2
   static WM_RBUTTONUP := 0x205
   if (lp = WM_RBUTTONUP &amp;&amp; (hwnd = hAssociatedGui1 || hwnd = hAssociatedGui2))
      Menu, MyTrayMenu, Show
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 13 Jul 2014 14:54:46 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=84741#p84741</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Двойная иконка в трее.]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=84728#p84728</link>
			<description><![CDATA[<p>Посмотрите, пожалуста, скриншот.<br />Обычно, когда запускаешь скрипт, в трее появляется соответствующая иконка.<br />(показал курсором на скриншоте).<br />Вопрос: Как сделать что бы при запуске <strong>одного</strong> скрипта в трее появилось сразу две (и более) иконки.<br />Повторяю, скрипт должен быть один, т.е. в диспетчере задач должен висеть один процесс.</p>]]></description>
			<author><![CDATA[null@example.com (Вася Пупкин)]]></author>
			<pubDate>Sat, 12 Jul 2014 14:35:47 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=84728#p84728</guid>
		</item>
	</channel>
</rss>
