<?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=8247</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=8247&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Позиционирование окна, в зависимости от позиции мыши».]]></description>
		<lastBuildDate>Thu, 17 Sep 2015 19:45:25 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=97539#p97539</link>
			<description><![CDATA[<p>Всё таки оно как то некорректно работает с двумя мониторами, или я что то не понял. В принципе стандартный тултип тоже в таких случаях ошибается. Пытался например сделать, чтобы от исходной точки окно было слева и по высоте посередине, но при приближении к краям окно уходит за какой нибудь край (при разных попытках реализации). </p><p>Желаемое, оказалось было не сложно сделать встроенными методами, вроде ошибок нет:<br /></p><div class="codebox"><pre><code>
#SingleInstance Force       
DetectHiddenWindows, On

Gui, Margin, 5, 5
Gui, Font, Italic s54 cWhite, Times New Roman
Gui, +AlwaysOnTop +ToolWindow -0x00400000 +E0x08000020 -DPIScale +Lastfound +HWNDhGui +Owner
Gui, Color, 2F4F4F 
WinSet, TransParent, 200

1::   
    DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, hStatic) 
    Gui Add, Text, hwndhStatic x5 y5, % &quot; TickCount: `n &quot; A_TickCount &quot; &quot;
    Gui, Show, % &quot;NA AutoSize &quot; (DllCall(&quot;IsWindowVisible&quot;, &quot;uint&quot;, hGui) ? &quot;&quot; : &quot;Hide&quot;)  
    WinGetPos, , , WinWidth, WinHeight, % &quot;ahk_id&quot; hGui 
    If CalculatePopupWindowPosition(X, Y, WinWidth, WinHeight, -WinWidth-45, -WinHeight//2) 
        Gui, Show, NA x%X% y%Y%
    Return

2:: Gui, Hide

CalculatePopupWindowPosition(byref left, byref top, w, h, offsetx = 0, offsety = 0, x = &quot;&quot;, y = &quot;&quot;)  {
    If (x = &quot;&quot; || y = &quot;&quot;)
        DllCall(&quot;GetCursorPos&quot;, &quot;int64P&quot;, pt), x := pt &lt;&lt; 32 &gt;&gt; 32, y := pt &gt;&gt; 32
    SysGet, MonCount, MonitorCount
    Loop % MonCount
    {
        SysGet, m, Monitor, %A_Index%
        If (x &gt;= mLeft &amp;&amp; x &lt;= mRight &amp;&amp; y &gt;= mTop &amp;&amp; y &lt;= mBottom)
            Break
        If (A_Index = MonCount)
            Return 0
    }
    left := x + offsetx + (offsetx &gt; 0) * w &lt; mLeft ? mLeft : x + offsetx + w &gt; mRight ? mRight - w : x + offsetx
    top := y + offsety + (offsety &gt; 0) * h &lt; mTop ? mTop : y + offsety + h &gt; mBottom ? mBottom - h : y + offsety
    Return 1
}
</code></pre></div><p>Но только стоит учитывать, что если указываются свои координаты показа, то они должны находится в пределах монитора.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 17 Sep 2015 19:45:25 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=97539#p97539</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90418#p90418</link>
			<description><![CDATA[<p>Небольшой пример. Под локальную переменную <em>Test</em> место в памяти выделяется вслед за <em>structs</em>. При многократном нажатии &#039;1&#039; и случайном перемещении курсора Test портится &quot;лишними&quot; данными. (win8.1 x86)<br /></p><div class="codebox"><pre><code>Gui, Margin, 5, 5
Gui, Font, Italic s34 cWhite, Times New Roman
Gui, +AlwaysOnTop +ToolWindow -0x00400000 +E0x08000020 -DPIScale +Lastfound +HWNDhGui  +Owner
Gui, Color, 2F4F4F 
WinSet, TransParent, 200

1:: 
    DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, hStatic)
    Gui Add, Text, hwndhStatic x5 y5, % &quot;TickCount:`n&quot; A_TickCount
    Gui, Show, % &quot;NA AutoSize &quot; (DllCall(&quot;IsWindowVisible&quot;, &quot;uint&quot;, hGui) ? &quot;&quot; : &quot;Hide&quot;) 
    If CalculatePopupWindowPosition(x, y, hGui, 25)
        Gui, Show, NA x%x% y%y% 
    Return 
    
2:: Gui, Hide

CalculatePopupWindowPosition(byref left, byref top, hwnd, offset = 0, x = &quot;&quot;, y = &quot;&quot;)  { 
    VarSetCapacity(POINT, 8, 0), VarSetCapacity(structs, 16, 0), VarSetCapacity(Test, 8, 0)
    If (x = &quot;&quot; || y = &quot;&quot;)
        DllCall(&quot;GetCursorPos&quot;, &quot;ptr&quot;, &amp;POINT)
    Else
        NumPut(x, POINT, 0, &quot;int&quot;), NumPut(y, POINT, 4, &quot;int&quot;)  
    DHW := A_DetectHiddenWindows
    DetectHiddenWindows, On
    WinGetPos, , , w, h, ahk_id %hwnd% 
    DetectHiddenWindows, %DHW%
    NumPut(w + offset, structs, 0, &quot;int&quot;), NumPut(h + offset, structs, 4, &quot;int&quot;) ; SIZE   
    Loop 2
    {
        If !DllCall(&quot;CalculatePopupWindowPosition&quot;
            , &quot;ptr&quot;, &amp;POINT
            , &quot;ptr&quot;, &amp;structs
            , &quot;int&quot;, [0, 0x0008][A_Index]
            , &quot;ptr&quot;, 0
            , &quot;ptr&quot;, &amp;structs + 8)
            Return 0 
        _left := NumGet(structs, 8, &quot;int&quot;), _top := NumGet(structs, 12, &quot;int&quot;) 
        If !(_left &lt; NumGet(POINT, 0, &quot;int&quot;) &amp;&amp; _top &lt; NumGet(POINT, 4, &quot;int&quot;)  &amp;&amp; (out := 1))    
            Break 
    }
    left := _left + (out ? 0 : offset)  
    top := _top + (out ? 0 : offset)
    ListVars
    Return 1
}
  
Esc:: ExitApp   </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Irbis)]]></author>
			<pubDate>Tue, 13 Jan 2015 10:24:25 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90418#p90418</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90416#p90416</link>
			<description><![CDATA[<p>Конечно. Функция ждёт указатель на 16 байт. И вы никак ей не скажете, что там для неё только 8.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Tue, 13 Jan 2015 08:58:22 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90416#p90416</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90415#p90415</link>
			<description><![CDATA[<p>То есть в таком варианте,&nbsp; изменяются следующие 8 байт адресного пространства процесса,&nbsp; отвечающих уже неизвестно за что?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 13 Jan 2015 08:53:20 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90415#p90415</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90407#p90407</link>
			<description><![CDATA[<p>Да, это ведь не AutoHotkey, где можно опускать ненужное. С WinAPI такие фокусы не пройдут.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Tue, 13 Jan 2015 07:02:00 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90407#p90407</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90406#p90406</link>
			<description><![CDATA[<p>Нам - не интересны. Но <em>CalculatePopupWindowPosition</em> об этом &quot;не знает&quot; и честно заполнит все 4 выходных параметра, выехав за пределы выделенной области. Какие данные при этом могут затереться, кто знает?</p>]]></description>
			<author><![CDATA[null@example.com (Irbis)]]></author>
			<pubDate>Tue, 13 Jan 2015 06:54:38 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90406#p90406</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90404#p90404</link>
			<description><![CDATA[<div class="codebox"><pre><code>typedef struct tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT</code></pre></div><p>Знаю, но какой смысл, если right и bottom нам не интересны.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 13 Jan 2015 06:36:56 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90404#p90404</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90401#p90401</link>
			<description><![CDATA[<p>SIZE + RECT = 24 байта, а не 16.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Tue, 13 Jan 2015 03:01:46 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90401#p90401</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90387#p90387</link>
			<description><![CDATA[<p>Или лучше так, чтобы мышь не наезжала на ToolTip.<br /></p><div class="codebox"><pre><code>
Gui, Margin, 5, 5
Gui, Font, Italic s34 cWhite, Times New Roman
Gui, +AlwaysOnTop +ToolWindow -0x00400000 +E0x08000020 -DPIScale +Lastfound +HWNDhGui  +Owner
Gui, Color, 2F4F4F 
WinSet, TransParent, 200

1:: 
    DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, hStatic)
    Gui Add, Text, hwndhStatic x5 y5, % &quot;TickCount:`n&quot; A_TickCount
    Gui, Show, % &quot;NA AutoSize &quot; (DllCall(&quot;IsWindowVisible&quot;, &quot;uint&quot;, hGui) ? &quot;&quot; : &quot;Hide&quot;) 
    If CalculatePopupWindowPosition(x, y, hGui, 25)
        Gui, Show, NA x%x% y%y% 
    Return 
    
2:: Gui, Hide

CalculatePopupWindowPosition(byref left, byref top, hwnd, offset = 0, x = &quot;&quot;, y = &quot;&quot;)  { 
    VarSetCapacity(POINT, 8, 0), VarSetCapacity(structs, 24, 0)
    If (x = &quot;&quot; || y = &quot;&quot;)
        DllCall(&quot;GetCursorPos&quot;, &quot;ptr&quot;, &amp;POINT)
    Else
        NumPut(x, POINT, 0, &quot;int&quot;), NumPut(y, POINT, 4, &quot;int&quot;)  
    DHW := A_DetectHiddenWindows
    DetectHiddenWindows, On
    WinGetPos, , , w, h, ahk_id %hwnd% 
    DetectHiddenWindows, %DHW%
    NumPut(w + offset, structs, 0, &quot;int&quot;), NumPut(h + offset, structs, 4, &quot;int&quot;) ; SIZE   
    Loop 2
    {
        If !DllCall(&quot;CalculatePopupWindowPosition&quot;
            , &quot;ptr&quot;, &amp;POINT
            , &quot;ptr&quot;, &amp;structs
            , &quot;int&quot;, [0, 0x0008][A_Index]
            , &quot;ptr&quot;, 0
            , &quot;ptr&quot;, &amp;structs + 8)
            Return 0 
        _left := NumGet(structs, 8, &quot;int&quot;), _top := NumGet(structs, 12, &quot;int&quot;) 
        If !(_left &lt; NumGet(POINT, 0, &quot;int&quot;) &amp;&amp; _top &lt; NumGet(POINT, 4, &quot;int&quot;)  &amp;&amp; (out := 1))    
            Break 
    }
    left := _left + (out ? 0 : offset)  
    top := _top + (out ? 0 : offset)
    Return 1
}
  
Esc:: ExitApp   
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 12 Jan 2015 22:19:55 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90387#p90387</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90373#p90373</link>
			<description><![CDATA[<p>Сделал такой вариант:<br /></p><div class="codebox"><pre><code>
Gui, Margin, 5, 5
Gui, Font, Italic s54 cWhite, Times New Roman
Gui, +AlwaysOnTop +ToolWindow -0x00400000 +E0x08000020 -DPIScale +Lastfound +HWNDhGui  +Owner
Gui, Color, 2F4F4F 
WinSet, TransParent, 200

1::   
    DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, hStatic)
    Gui Add, Text, hwndhStatic x5 y5, % &quot;TickCount:`n&quot; A_TickCount
    Gui, Show, % &quot;NA AutoSize &quot; (DllCall(&quot;IsWindowVisible&quot;, &quot;uint&quot;, hGui) ? &quot;&quot; : &quot;Hide&quot;) 
    If CalculatePopupWindowPosition(x, y, hGui, 15)
        Gui, Show, NA x%x% y%y%
    Return 
    
2:: Gui, Hide

CalculatePopupWindowPosition(byref left, byref top, hwnd, offset = 0, x = &quot;&quot;, y = &quot;&quot;)  { 
    VarSetCapacity(POINT, 8, 0), VarSetCapacity(structs, 24, 0)
    If (x = &quot;&quot; || y = &quot;&quot;)
        DllCall(&quot;GetCursorPos&quot;, &quot;ptr&quot;, &amp;POINT)
    Else
        NumPut(x, POINT, 0, &quot;int&quot;), NumPut(y, POINT, 4, &quot;int&quot;)  
    DHW := A_DetectHiddenWindows
    DetectHiddenWindows, On
    WinGetPos, , , w, h, ahk_id %hwnd% 
    DetectHiddenWindows, %DHW%
    NumPut(w + offset, structs, 0, &quot;int&quot;), NumPut(h + offset, structs, 4, &quot;int&quot;) ; SIZE  
    If !DllCall(&quot;CalculatePopupWindowPosition&quot;
        , &quot;ptr&quot;, &amp;POINT
        , &quot;ptr&quot;, &amp;structs
        , &quot;int&quot;, 0x0040        ; TPM_VERTICAL
        , &quot;ptr&quot;, 0
        , &quot;ptr&quot;, &amp;structs + 8)
        Return 0
    left  := NumGet(structs, 8, &quot;int&quot;) + offset
    top := NumGet(structs, 12, &quot;int&quot;) + offset 
    Return 1
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 12 Jan 2015 21:04:43 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90373#p90373</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90358#p90358</link>
			<description><![CDATA[<p><strong>YMP</strong><br />Большое спасибо за пример! Может не обращал нигде внимание до этого, но интересен также пример использования одной структуры под &quot;всё&quot;.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 12 Jan 2015 09:12:07 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90358#p90358</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90356#p90356</link>
			<description><![CDATA[<p>Нет, там указатели на структуры.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Вот их определения</div><div class="fancy_spoiler"><div class="codebox"><pre><code>
typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT

typedef struct tagSIZE
{
    LONG        cx;
    LONG        cy;
} SIZE

typedef struct tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT
</code></pre></div></div></div><p>Т.е. вот так можно, например.<br /></p><div class="codebox"><pre><code>
x := A_ScreenWidth
y := A_ScreenHeight  
w := 222
h := 222

VarSetCapacity( structs, 32, 0 )
NumPut( x, structs, 0, &quot;int&quot; ), NumPut( y, structs, 4, &quot;int&quot; )  ; POINT
NumPut( w, structs, 8, &quot;int&quot; ), NumPut( h, structs, 12, &quot;int&quot; ) ; SIZE

If !DllCall( &quot;CalculatePopupWindowPosition&quot;
    , &quot;ptr&quot;, &amp;structs
    , &quot;ptr&quot;, &amp;structs + 8
    , &quot;uint&quot;, 0x10000        ; TPM_WORKAREA
    , &quot;ptr&quot;, 0
    , &quot;ptr&quot;, &amp;structs + 16 )
{
    MsgBox, Ошибка.
    ExitApp
}
; Выходной RECT
left  := NumGet( structs, 16, &quot;int&quot; ), top    := NumGet( structs, 20, &quot;int&quot; )
right := NumGet( structs, 24, &quot;int&quot; ), bottom := NumGet( structs, 28, &quot;int&quot; )

MsgBox, %left% %top%`n%right% %bottom%
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Mon, 12 Jan 2015 08:52:09 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90356#p90356</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90353#p90353</link>
			<description><![CDATA[<p>Писал я. Везде добавил звёздочки, ничего. Делал по аналогии с другими функциями, &quot;int64&quot; - входящий параметр в виде структуры, &quot;int64*&quot; - исходящий параметр в виде структуры.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 12 Jan 2015 08:29:06 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90353#p90353</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90351#p90351</link>
			<description><![CDATA[<p>Не знаете, что такое указатель? Однако в 5-м параметре вы его используете. Или это не вы код писали?</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Mon, 12 Jan 2015 08:11:57 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90351#p90351</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Позиционирование окна, в зависимости от позиции мыши]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=90350#p90350</link>
			<description><![CDATA[<p>Не наводит на мысли, я в этом ровным счётом ничего не понимаю.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 12 Jan 2015 07:58:37 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=90350#p90350</guid>
		</item>
	</channel>
</rss>
