<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK v2: Альтернатива стандартному ToolTip]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=18479</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=18479&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK v2: Альтернатива стандартному ToolTip».]]></description>
		<lastBuildDate>Fri, 22 Aug 2025 13:57:28 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK v2: Альтернатива стандартному ToolTip]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=162636#p162636</link>
			<description><![CDATA[<p>Конвертация <a href="https://forum.script-coding.com/viewtopic.php?id=18258">версии для AHK v1</a>.</p><p>Возможности альтернативного Tooltip:<br /></p><ul><li><p>Включение прозрачности, в том числе прозрачность для кликов мышью;</p></li><li><p>Автоматическое пропадание после указанного времени;</p></li><li><p>Пропадание при нажатии;</p></li><li><p>Изменение параметров шрифта;</p></li><li><p>Изменение цвета фона;</p></li><li><p>Уменьшенное мерцание при частом обновлении текста;</p></li><li><p>Работа с несколькими мониторами.</p></li></ul><p><a href="https://forum.script-coding.com/viewtopic.php?pid=162637#p162637">Тема для обсуждения.</a></p><div class="codebox"><pre><code>
class Tool_Tip
{
  ; #requires AutoHotkey v2.0.19
  ; Tool_Tip by Alectric
  ; https://forum.script-coding.com/
  ; Метод 	Show(Text:=&quot;&quot;,X:=&quot;&quot;,Y:=&quot;&quot;,Delay:=0,Trans:=&quot;&quot;,BackColor:=&quot;&quot;,Font:=&quot;&quot;,FontName:=&quot;&quot;,WW:=0,HH:=0)
  ; 	Text		- Текст который необходимо отобразить
  ; 	X, Y		- Координаты появления относительно экрана
  ; 	Delay		- задержка пропадания после вызова в миллисекундах
  ; 	Trans		- Прозрачность в формате AHK Gui (но от 2 до 255), false - не прозрачно, true - прозрачность=180; (также становится прозрачен для кликов мыши)
  ; 	BackColor	- Цвет фона
  ; 	Font		- Параметры шрифта в формате Gui (цвет, размер, наклон, толщина, подчеркнутый, зачеркнутый)
  ; 	FontName	- Название шрифта
  ; 	WW, HH		- Фиксированные ширина и высота (если оба значения не 0, то отрисовка в ~5 раз быстрее)
  ;
  ; Метод Hide()	- Скрывает Tooltip
  ;
  ; Свойство Pos	- Возвращает объект с параметрами окна {X:X,Y:Y,W:W,H:H}.

  static DPICoef:=Tool_Tip.GetDPICoef()

  __Delete()
  {
    ObjAddRef(ObjPtr(this))
    SetTimer this.obm,0
    this.TTW.Destroy()
    this.obm:=unset
;    tooltip &quot;Деструктор вызван&quot;
;    sleep 1000
;    tooltip
  }

  __New()
  {
    this.Visible:=false
    this.X:=0
    this.Y:=0
    this.W:=0
    this.H:=0
    this.BackColor:=&quot;0xFFFFFF&quot;
    this.Trans:=255
    this.Text:=&quot;&quot;
    this.Font:=&quot;s9&quot;
    this.FontName:=&quot;Arial&quot;
    this.TTW:=Gui(&quot;+ToolWindow -sysmenu -Resize +AlwaysOnTop -Caption +Border +E0x2080000&quot;)
    this.TTW.SetFont(this.Font,this.FontName)
    this.TTW.BackColor:=this.BackColor
    this.TTW.MarginX:=2
    this.TTW.MarginY:=2
    this.TTT:=this.TTW.Add(&quot;Text&quot;)
    this.obm:=ObjBindMethod(this,&quot;Hide&quot;)
    ObjRelease(ObjPtr(this))
    this.TTW.OnEvent(&quot;ContextMenu&quot;,this.obm)
    this.TTT.OnEvent(&quot;Click&quot;,this.obm)
  }

  Pos
  {
    get
    {
      this.TTW.GetPos(&amp;X,&amp;Y,&amp;W,&amp;H)
      return {X:X,Y:Y,W:W,H:H}
    }
  }

  Hide(*)
  {
    this.TTW.Hide()
    this.Visible:=false
  }

  Show(Text:=&quot;&quot;,X:=&quot;&quot;,Y:=&quot;&quot;,Delay:=0,Trans:=&quot;&quot;,BackColor:=&quot;&quot;,Font:=&quot;&quot;,FontName:=&quot;&quot;,WW:=0,HH:=0)
  {
    SaveCoordMode:=A_CoordModeMouse
    CoordMode &quot;Mouse&quot;,&quot;Screen&quot;
    MouseGetPos(&amp;mX,&amp;mY,&amp;mW,&amp;mC,2)
    CoordMode &quot;Mouse&quot;,SaveCoordMode
    if (X=&quot;&quot;)
      X:=mX+10
    if (Y=&quot;&quot;)
      Y:=mY+20
    if ((Font!=&quot;&quot; and Font!=this.Font) or (FontName!=&quot;&quot; and FontName!=this.FontName))
    {
      this.Font:=Font
      this.FontName:=FontName
      this.TTT.SetFont(this.Font,this.FontName)
    }
    W:=this.W
    H:=this.H
    if (Text!=&quot;&quot; and Text!=this.Text)
    {
      this.Text:=Text
      if (!WW or !HH)
      {
        ControlSetStyle(&quot;-1&quot;,this.TTT)
        Size:=this.Measure(Text)
      }
      else
      {
        ControlSetStyle(&quot;+1&quot;,this.TTT)
        Size:={X:X,Y:Y,W:WW,H:HH}
      }
      this.TTT.Move(,,Size.W,Size.H)
      this.TTT.Value:=Text
      W:=Size.W+8
      H:=Size.H+8
    }
    B:=this.Bound(X,Y,W,H)
    W:=Round(W/Tool_Tip.DPICoef)
    H:=Round(H/Tool_Tip.DPICoef)
    X:=B.X
    Y:=B.Y
    if (X!=this.X or Y!=this.Y or W!=this.W or H!=this.H or BackColor!=this.BackColor or !this.Visible)
    {
      this.X:=X
      this.Y:=Y
      this.W:=W
      this.H:=H
      this.Visible:=true
      if (BackColor!=&quot;&quot; and BackColor!=this.BackColor)
      {
        this.BackColor:=BackColor
        this.TTW.BackColor:=BackColor
      }
      this.TTW.show(&quot;x&quot; X &quot; y&quot; Y &quot; w&quot; W &quot; h&quot; H &quot; NoActivate&quot;)
    }
    if (Trans!=&quot;&quot; and Trans!=this.Trans)
    {
      this.Trans:=Trans
      if Trans
      {
        WinSetTransparent(Trans=1?180:Trans,this.TTW)
        WinSetExStyle(&quot;+0x20&quot;,this.TTW)
      }
      else
      {
        WinSetTransparent(255,this.TTW)
        WinSetExStyle(&quot;-0x20&quot;,this.TTW)
      }
    }
    SetTimer this.obm,-abs(Delay)
  }

  Measure(Text)
  {
    G:=Gui()
    G.SetFont(this.Font,this.FontName)
    G.MarginX:=2
    G.MarginY:=2
    T:=G.Add(&quot;Text&quot;,,Text)
    Controlgetpos(&amp;X,&amp;Y,&amp;W,&amp;H,T)
    G.Destroy()
    return {X:X,Y:Y,W:W,H:H}
  }

  Bound(X,Y,W:=0,H:=0)
  {
    this.last:=1
    Loop MonitorGetCount()
    {
      MonitorGet(A_Index,&amp;Left,&amp;Top,&amp;Right,&amp;Bottom)
      if (X&gt;=Left and X&lt;=Right and Y&gt;=Top and Y&lt;=Bottom)
      {
        MonitorGetWorkArea(A_Index,&amp;Left,&amp;Top,&amp;Right,&amp;Bottom)
        this.last:=a_index
        return {X:(X+W&gt;Right?Right-W:X)
               ,Y:(Y+H&gt;Bottom?Bottom-H:Y)
               ,B:a_index}
      }
    }
    MonitorGetWorkArea(this.last,&amp;Left,&amp;Top,&amp;Right,&amp;Bottom)
    return {X:(X+W&gt;Right?Right-W:X&lt;Left?Left:X)
           ,Y:(Y+H&gt;Bottom?Bottom-H:Y&lt;Top?Top:Y)
           ,B:this.last}
  }

  static GetDPICoef()
  {
    G:=Gui()
    T:=G.Add(&quot;Text&quot;,&quot;x0 y0 w1000 h1000&quot;)
    Controlgetpos(,,&amp;W,,T)
    G.Destroy()
    return W/1000
  }
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alectric)]]></author>
			<pubDate>Fri, 22 Aug 2025 13:57:28 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=162636#p162636</guid>
		</item>
	</channel>
</rss>
