<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Замена Tip на TrayTip]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=12627</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12627&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Замена Tip на TrayTip».]]></description>
		<lastBuildDate>Tue, 25 Apr 2017 20:18:10 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115319#p115319</link>
			<description><![CDATA[<p>Благодаря доработанному <strong>teadrinker</strong> классу <a href="http://forum.script-coding.com/viewtopic.php?id=12236">TrayTip</a> стало возможным сделать идеальную всплывающую подсказку к значку в трее: </p><div class="codebox"><pre><code>RemoveTip()  ; удаление дефолтной подсказки

global myTrayTip
myTrayTip := new ToolTip({ text: &quot;Закрепить окно`t`t`tCtrl Space`nРасчет выделенного выражения`tCtrl Shift =`nВыделенную сумму - прописью`tCtrl Shift W&quot;
                        , title: &quot;Горячие клавиши&quot;
                        , CloseButton: true
                        , Icon: 1              ; 1 — Info, 2 — Warning, 3 — Error, n &gt; 3 — предполагается hIcon
                        , TrayTip: true
                        , ShowNow: false})

OnMessage(0x404, &quot;WindowProc&quot;)

WindowProc(wParam,lParam,Msg,hwnd) {
   myTrayTip.Show(,, 2000)
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (mozers)]]></author>
			<pubDate>Tue, 25 Apr 2017 20:18:10 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115319#p115319</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115203#p115203</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Спасибо! Работает как положено.<br />Но, всё таки, это-ж просто офигеть сколько кода ради моей невинной затеи...<br />Мой вариант, конечно, примитивен и не так красиво срабатывает, но...</p><div class="codebox"><pre><code>Menu, Tray, Tip, % &quot;`t&quot; ; убираем (почти) оригинальную подсказку

OnMessage(0x404,&quot;WindowProc&quot;)

WindowProc(wParam,lParam,Msg,hwnd) {
	static tt
	If (lParam = 512) {
		If (!tt) {
			TrayTip, Горячие клавиши, Закрепить окно`t`t`tCtrl Space`nРасчет выделенного выражения`tCtrl Shift =`nВыделенную сумму - прописью`tCtrl Shift W, 1, 1
			tt := true
		}
	} else {
		tt := false
	}
}</code></pre></div><p>P.S. То, что на Win7 смотрелось вполне прилично, на Win10 не выдерживает никакой критики.<br />Пожалуй, самым универсальным вариантом будет скрестить код <strong>teadrinker</strong> из поста выше и его же TrayTip, выложенный <a href="http://forum.script-coding.com/viewtopic.php?id=12236">в Коллекции</a>.</p>]]></description>
			<author><![CDATA[null@example.com (mozers)]]></author>
			<pubDate>Thu, 20 Apr 2017 08:57:37 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115203#p115203</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115201#p115201</link>
			<description><![CDATA[<p>Вот так примерно:<br /></p><div class="codebox"><pre><code>#NoEnv
RemoveTip()  ; удаление дефолтной подсказки при наведении на иконку скрипта
OnMessage(0x404, Func(&quot;AHK_NOTIFYICON&quot;).Bind(&quot;Заголовок&quot;, &quot;Мой текст&quot;, 1))
Return

RemoveTip()  {
   static uID := 0x404, NIF_TIP := 4, NIM_MODIFY := 1
   
   VarSetCapacity(NOTIFYICONDATA, size := A_PtrSize = 8 ? 848 : A_IsUnicode? 828 : 444, 0)
   NumPut(size, NOTIFYICONDATA, &quot;UInt&quot;)
   NumPut(A_ScriptHwnd, NOTIFYICONDATA, A_PtrSize)
   NumPut(uID, NOTIFYICONDATA, 2*A_PtrSize, &quot;UInt&quot;)
   NumPut(NIF_TIP, NOTIFYICONDATA, 2*A_PtrSize + 4, &quot;UInt&quot;)
   NumPut(0, NOTIFYICONDATA, 4*A_PtrSize + 8)
   DllCall(&quot;shell32\Shell_NotifyIcon&quot;, &quot;UInt&quot;, NIM_MODIFY, Ptr, &amp;NOTIFYICONDATA)
}

AHK_NOTIFYICON(title, text, options, wp, lp)  {
   static WM_MOUSEMOVE := 0x200, showtip := []
   if (lp = WM_MOUSEMOVE &amp;&amp; !showtip[1])  {
      showtip[1] := true
      MouseGetPos,,,, hToolbar, 2
      TrayTip, % title, % text, 30, % options
      timer := Func(&quot;TraytipDel&quot;).Bind(showtip, hToolbar)
      SetTimer, % timer, 100
   }
}

TraytipDel(info, hToolbar)  {
   Loop 1  {
      if oPos := GetMousePosOnToolbar()  {
         VarSetCapacity(RECT, 16, 0)
         GetScriptIconPos(hToolbar, RECT)
         WinGetPos, xTB, yTB,,, ahk_id %hToolbar%
         POINT := (oPos.x - xTB) | (oPos.y - yTB) &lt;&lt; 32
         if DllCall(&quot;PtInRect&quot;, Ptr, &amp;RECT, Int64, POINT)
            break
      }
      try SetTimer,, Delete
      info[1] := false
      TrayTip
   }
}

GetMousePosOnToolbar()  {
   CoordMode, Mouse
   MouseGetPos, X, Y, hwnd
   WinGetClass, winClass, ahk_id %hwnd%
   if winClass not in Shell_TrayWnd,NotifyIconOverflowWindow,tooltips_class32
      Return
   
   Return {x: X, y: Y}
}

GetScriptIconPos(hToolbar, ByRef RECT)  {
   static WM_USER := 0x400, TB_BUTTONCOUNT := WM_USER + 24, TB_GETBUTTON := WM_USER + 23, TB_GETITEMRECT := WM_USER + 29
      , PtrSize := A_Is64bitOS ? 8 : 4, szTBBUTTON := 8 + PtrSize*3, szTRAYDATA := 16 + PtrSize*2
      
   WinExist(&quot;ahk_id&quot; hToolbar)
   WinGet, PID, PID
   RemoteBuff := New RemoteBuffer(PID, szTBBUTTON)
   
   SendMessage, TB_BUTTONCOUNT
   Loop % ErrorLevel  {
      SendMessage, TB_GETBUTTON, A_Index - 1, RemoteBuff.ptr
      pTBBUTTON := RemoteBuff.Read(szTBBUTTON)
      TraydataOffset := NumGet(pTBBUTTON + 8 + PtrSize) - RemoteBuff.ptr
      pTRAYDATA := RemoteBuff.Read(szTRAYDATA, TraydataOffset)
      hWnd := NumGet(pTRAYDATA + 0, PtrSize = 4 ? &quot;UInt&quot; : &quot;UInt64&quot;)
      if (hWnd != A_ScriptHwnd)
         continue
      
      SendMessage, TB_GETITEMRECT, A_Index - 1, RemoteBuff.ptr
      pRECT := RemoteBuff.Read(16)
      DllCall(&quot;RtlMoveMemory&quot;, Ptr, &amp;RECT, Ptr, pRECT, Ptr, 16)
      break
   }
}

class RemoteBuffer
{
   __New(PID, size)  {
      static PROCESS_VM_OPERATION := 0x8, PROCESS_VM_WRITE := 0x20
           , PROCESS_VM_READ := 0x10, MEM_COMMIT := 0x1000, PAGE_READWRITE := 0x4
         
      if !(this.hProc := DllCall(&quot;OpenProcess&quot;, UInt, PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE, Int, 0, UInt, PID, Ptr))
         Return
      
      if !(this.ptr := DllCall(&quot;VirtualAllocEx&quot;, Ptr, this.hProc, Ptr, 0, Ptr, size, UInt, MEM_COMMIT, UInt, PAGE_READWRITE, Ptr))
         Return, &quot;&quot;, DllCall(&quot;CloseHandle&quot;, Ptr, this.hProc)
      
      this.hHeap := DllCall(&quot;GetProcessHeap&quot;, Ptr)
   }
   
   __Delete()  {
      DllCall(&quot;VirtualFreeEx&quot;, Ptr, this.hProc, Ptr, this.ptr, UInt, 0, UInt, MEM_RELEASE := 0x8000)
      DllCall(&quot;CloseHandle&quot;, Ptr, this.hProc)
      DllCall(&quot;HeapFree&quot;, Ptr, this.hHeap, UInt, 0, Ptr, this.pHeap)
   }
   
   Read(size, offset = 0)  {
      (this.pHeap &amp;&amp; DllCall(&quot;HeapFree&quot;, Ptr, this.hHeap, UInt, 0, Ptr, this.pHeap))
      this.pHeap := DllCall(&quot;HeapAlloc&quot;, Ptr, this.hHeap, UInt, HEAP_ZERO_MEMORY := 0x8, Ptr, size, Ptr)
      if !DllCall(&quot;ReadProcessMemory&quot;, Ptr, this.hProc, Ptr, this.ptr + offset, Ptr, this.pHeap, Ptr, size, Int, 0)
         Return, 0, DllCall(&quot;MessageBox&quot;, Ptr, 0, Str, &quot;Не удалось прочитать данные`nОшибка &quot; A_LastError, Str, &quot;&quot;, UInt, 0)
      Return this.pHeap
   }
   
   Write(pLocalBuff, size, offset = 0)  {
      if !res := DllCall(&quot;WriteProcessMemory&quot;, Ptr, this.hProc, Ptr, this.ptr + offset, Ptr, pLocalBuff, Ptr, size, PtrP, writtenBytes)
         DllCall(&quot;MessageBox&quot;, Ptr, 0, Str, &quot;Не удалось записать данные`nОшибка &quot; A_LastError, Str, &quot;&quot;, UInt, 0)
      Return writtenBytes
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 19 Apr 2017 22:54:09 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115201#p115201</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115195#p115195</link>
			<description><![CDATA[<div class="quotebox"><cite>mozers пишет:</cite><blockquote><p>Как выводить TrayTip при наведении на иконку</p></blockquote></div><div class="codebox"><pre><code>#Persistent
VarSetCapacity(NOTIFYICONDATA, size := A_PtrSize = 8 ? 848 : A_IsUnicode? 828 : 444, 0)
NumPut(size, NOTIFYICONDATA, &quot;UInt&quot;)
NumPut(A_ScriptHwnd, NOTIFYICONDATA, A_PtrSize)
NumPut(0x404, NOTIFYICONDATA, 2*A_PtrSize, &quot;UInt&quot;)
NumPut(NIF_TIP := 4, NOTIFYICONDATA, 2*A_PtrSize + 4, &quot;UInt&quot;)
NumPut(0, NOTIFYICONDATA, 4*A_PtrSize + 8)
DllCall(&quot;shell32\Shell_NotifyIcon&quot;, &quot;UInt&quot;, NIM_MODIFY := 1, Ptr, &amp;NOTIFYICONDATA)

OnMessage(0x404, Func(&quot;AHK_NOTIFYICON&quot;).Bind(&quot;Заголовок&quot;, &quot;Мой текст&quot;, 2, 1))
Return

AHK_NOTIFYICON(title, text, seconds, options, wp, lp)  {
   static WM_MOUSEMOVE := 0x200, showtip := []
   if (lp = WM_MOUSEMOVE &amp;&amp; !showtip[1])  {
      showtip[1] := true
      TrayTip, % title, % text, 30, % options
      timer := Func(&quot;TraytipDel&quot;).Bind(showtip)
      SetTimer, % timer, % &quot;-&quot; . (seconds * 1000)
   }
}

TraytipDel(info)  {
   info[1] := false
   TrayTip
}</code></pre></div><div class="quotebox"><cite>mozers пишет:</cite><blockquote><p>и скрывать при уходе курсора с иконки?</p></blockquote></div><p>Событие ухода курсора отслеживается системой, но с помощью AHK_NOTIFYICON, вроде, его отследить не получится. Можно с помощью относительно сложного кода по таймеру получать координаты иконки и курсора.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 19 Apr 2017 20:00:10 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115195#p115195</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115194#p115194</link>
			<description><![CDATA[<p><strong>ypppu</strong>, абсолютно точно! Эксперементально нашёл это ограничение (127 байт), а потом, прочитав твой пост, понял что документацию я читаю невнимательно. Но, правда, там надо еще дописать что табуляторы не допускаются (текст тупо обрезается после первого из них).<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Но скорее всего можно туда отправить пустую строку</p></blockquote></div><p>Спасибо, понял. Завтра проверю.</p><p>Остается вопрос - Как выводить <span style="color: blue">TrayTip</span> при наведении на иконку и скрывать при уходе курсора с иконки?<br />Т.е. чтобы <span style="color: blue">TrayTip</span> работал идентично <span style="color: blue">Menu, Tray, Tip</span>.</p>]]></description>
			<author><![CDATA[null@example.com (mozers)]]></author>
			<pubDate>Wed, 19 Apr 2017 19:43:50 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115194#p115194</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115193#p115193</link>
			<description><![CDATA[<p>В NOTIFYICONDATA тоже есть ограничение по длине. Но скорее всего можно туда отправить пустую строку, в отличие от <em>Menu, Tray, Tip</em>.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 19 Apr 2017 19:16:39 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115193#p115193</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115190#p115190</link>
			<description><![CDATA[<p>Вроде ж есть&nbsp; ограничение.<br /></p><div class="quotebox"><cite>YMP пишет:</cite><blockquote><p><span style="color: navy"><strong>Menu, MenuName, Cmd [, P3, P4, P5]</strong></span><br />...<br />Tip [, Text] Изменяет подсказку значка в трее, которая появляется при наведении на него курсора мыши. Чтобы подсказка состояла из нескольких строк, используйте перевод строки (`n), например, Строка1`nСтрока2. Максимальная длина воспроизводимого текста - 127 символов. Если параметр Text опущен, это приведёт к показу текста по умолчанию. Встроенная переменная A_IconTip содержит текущий текст подсказки (пуста, если текст - по умолчанию).</p></blockquote></div><p> Или речь про другую документацию?</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Wed, 19 Apr 2017 19:04:02 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115190#p115190</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115189#p115189</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, спасибо за наводку. Пытаюсь разобраться...<br />А более простого пути впихнуть в <span style="color: blue">Menu, Tray, Tip</span> мой текст нет? Просто в документации ни о каких ограничениях на текст подсказки не упоминается...</p>]]></description>
			<author><![CDATA[null@example.com (mozers)]]></author>
			<pubDate>Wed, 19 Apr 2017 18:46:17 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115189#p115189</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115180#p115180</link>
			<description><![CDATA[<p>Подсказка при наведении прописана в <a href="https://msdn.microsoft.com/ru-ru/library/windows/desktop/bb773352(v=vs.85).aspx">NOTIFYICONDATA</a> (параметр TCHAR szTip[64]). Изменить эту структуру можно функцией <a href="https://msdn.microsoft.com/ru-ru/library/windows/desktop/bb762159(v=vs.85).aspx">Shell_NotifyIcon</a>.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 19 Apr 2017 15:35:41 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115180#p115180</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Замена Tip на TrayTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115177#p115177</link>
			<description><![CDATA[<p>Пытаюсь заменить <span style="color: blue">Menu, Tray, Tip</span> (т.к. текст большой не влазит) на <span style="color: blue">TrayTip</span> (он выводит просто замечательно, красиво и с иконкой).<br /></p><div class="codebox"><pre><code>Menu, Tray, Tip, % &quot;&quot; ; понимаю что неправильно, но как отменить его появление ???

OnMessage(0x404,&quot;WindowProc&quot;)  ; м.б. можно вызвать TrayTip как то проще???
Return

WindowProc(wParam,lParam,Msg,hwnd)  { 
	TrayTip, Горячие клавиши, Закрепить окно`t`t`tCtrl Space`nРасчет выделенного выражения`tCtrl Shift =`nВыделенную сумму - прописью`tCtrl Shift W, 2, 1
}</code></pre></div><p>Проблемы:<br />1. Родной <span style="color: blue">Menu, Tray, Tip</span> при наведении мыши на иконку в трее все равно возникает. Как его убить насовсем???<br />2. При наведении мыши на иконку в трее заданный <span style="color: blue">TrayTip</span> выскакивает, но не исчезает.</p>]]></description>
			<author><![CDATA[null@example.com (mozers)]]></author>
			<pubDate>Wed, 19 Apr 2017 14:45:19 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115177#p115177</guid>
		</item>
	</channel>
</rss>
