<?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=8796</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8796&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Определить контрол по координатам».]]></description>
		<lastBuildDate>Tue, 22 Oct 2013 04:24:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76318#p76318</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p><strong>Malcev</strong><br />Это можно и попроще записать:</p></blockquote></div><p>Похоже это то что нужно! <br />От <strong>WinGet, ListControl, ControlList</strong> ранее отказался, т.к. он возвращал отсортированный список (Static1, Static2...), а у меня Picture передвигаемые. <br />Решил накодить на AHK &quot;Три в ряд&quot;)), задача с определением контрола решена, спасибо, будем думать дальше.</p>]]></description>
			<author><![CDATA[null@example.com (Zohann)]]></author>
			<pubDate>Tue, 22 Oct 2013 04:24:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76318#p76318</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76316#p76316</link>
			<description><![CDATA[<p>Да, что то размытые критерии.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 22:45:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76316#p76316</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76315#p76315</link>
			<description><![CDATA[<p>Я не знаю. Но ведь работает же.<br />Может потому, что контролы располагаются от большего к меньшему &quot;матрешкой&quot;?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 21 Oct 2013 21:59:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76315#p76315</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76314#p76314</link>
			<description><![CDATA[<p><strong>Malcev</strong><br />Это можно и попроще записать:<br /></p><div class="codebox"><pre><code>

1::  MsgBox % CoordGetControl(23, 349, WinExist(&quot;A&quot;)) 
    
CoordGetControl(tX, tY, hActWin)   {
    WinGet, ListControl, ControlList, ahk_id %hActWin%  
    Loop, parse, ListControl, `n
    {
        ControlGetPos, cX, cY, cW, cH, %A_LoopField%, ahk_id %hActWin% 
        If (cX &lt;= tX &amp;&amp; cY &lt;= tY &amp;&amp; cX + cW &gt;= tX &amp;&amp; cY + cH &gt;= tY) 
            (LastMinArea &gt;= cW * cH || LastMinArea = &quot;&quot;) 
            ? (LastMinArea := cW * cH, Control := A_LoopField) :  &quot;&quot; 
    }
    Return Control
}

</code></pre></div><p>Принцип тот же. </p><p>Но почему вы думаете что нужный нам контрол (естественно подходящий под координаты), это обязательно тот, который ниже по списку, и меньшей площадью?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 21:05:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76314#p76314</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76313#p76313</link>
			<description><![CDATA[<p>Слизал с оф.форума.<br /></p><div class="codebox"><pre><code>F3::
ActiveHwnd := WinExist(&quot;A&quot;)
Control := CoordGetControl(&quot;33&quot;,&quot;186&quot;, ActiveHwnd)
msgbox % Control
Return

CoordGetControl(xCoord, yCoord, _hWin) ; _hWin should be the ID of the active window
{
    CtrlArray := Object() 
    WinGet, ControlList, ControlList, ahk_id %_hWin%
    Loop, Parse, ControlList, `n
    {
        Control := A_LoopField
        ControlGetPos, left, top, right, bottom, %Control%, ahk_id %_hWin%
      right += left, bottom += top
        if (xCoord &gt;= left &amp;&amp; xCoord &lt;= right &amp;&amp; yCoord &gt;= top &amp;&amp; yCoord &lt;= bottom)
            MatchList .= Control &quot;|&quot;
    }
    StringTrimRight, MatchList, MatchList, 1
    Loop, Parse, MatchList, |
    {
        ControlGetPos,,, w, h, %A_LoopField%, ahk_id %_hWin%
        Area := w * h
        CtrlArray[Area] := A_LoopField
    }
    for Area, Ctrl in CtrlArray
    {
        Control := Ctrl
        if A_Index = 1
            break
    }
    return Control
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 21 Oct 2013 19:59:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76313#p76313</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76311#p76311</link>
			<description><![CDATA[<p><strong>Malcev</strong><br /></p><div class="codebox"><pre><code>
1::
tX := 23, tY := 349
hActWin := WinExist(&quot;A&quot;)
WinGet, ListControl, ControlList, ahk_id %hActWin% 
 
Loop, parse, ListControl, `n
{
    ControlGetPos, cX, cY, cW, cH, %A_LoopField%, ahk_id %hActWin% 
    If (cX &lt;= tX &amp;&amp; cY &lt;= tY &amp;&amp; cX + cW &gt;= tX &amp;&amp; cY + cH &gt;= tY)
    {   
        ControlGet, Visible, Visible,, %A_LoopField%, ahk_id %hActWin% 
        If Visible
            MsgBox,, %tX% - %tY%, %A_LoopField% `n x%cX% w%cW% y%cY% h%cH% 
    }
}
</code></pre></div><p>Вот только много совпадений. Посмотрите на калькуляторе например кнопку 7.</p><p>ап:<br />Так вместо 5, 3 совпадения:<br /></p><div class="codebox"><pre><code>

1::
tX := 23, tY := 349
hActWin := WinExist(&quot;A&quot;)
WinGet, ListControl, ControlList, ahk_id %hActWin% 
 
Loop, parse, ListControl, `n
{
    ControlGetPos, cX, cY, cW, cH, %A_LoopField%, ahk_id %hActWin%
    If (cX &gt; tX || cY &gt; tY)
        Continue
    If (cX + cW &gt;= tX &amp;&amp; cY + cH &gt;= tY)
    {   
        ControlGet, Visible, Visible,, %A_LoopField%, ahk_id %hActWin% 
        If Visible
            MsgBox,, %tX% - %tY%, %A_LoopField% `n x%cX% w%cW% y%cY% h%cH% `n Vis %Vis% 
    }
}

</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 19:02:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76311#p76311</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76281#p76281</link>
			<description><![CDATA[<p>В принципе если по hWnd требуется узнавать classnn контрола <span class="bbu">и порядковый номер</span>, то&nbsp; ControlList всё таки тоже придётся получать.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 14:49:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76281#p76281</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76280#p76280</link>
			<description><![CDATA[<p><strong>Malcev</strong><br />Можно, кто сказал нельзя. Применить для каждого ControlGetPos, просто может занять много времени для большого списка, зато можно узнавать и в свёрнутом окне какой контрол находится в заданных координатах.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 14:40:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76280#p76280</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76279#p76279</link>
			<description><![CDATA[<p>А почему нельзя получить список всех контролов и потом узнать к какому из них принадлежат ваши x и y.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 21 Oct 2013 14:06:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76279#p76279</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76277#p76277</link>
			<description><![CDATA[<p>Возвращает хэндл контрола, а что нужно то? И Window Spy что может показать?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 13:51:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76277#p76277</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76271#p76271</link>
			<description><![CDATA[<p>А что за 7-значные цифры эта функция возвращает? Использую на <strong>Gui, Add, Picture</strong>. Window Spy ничего похожего не показывает.</p>]]></description>
			<author><![CDATA[null@example.com (Zohann)]]></author>
			<pubDate>Mon, 21 Oct 2013 12:12:28 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76271#p76271</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76268#p76268</link>
			<description><![CDATA[<p>Можно немного упростить запись:<br /></p><div class="codebox"><pre><code>

SetFormat, IntegerFast, h

loop  
    ToolTip % hWndFromPoint( 100, 100) 
 
hWndFromPoint( x, y)
{
    Static h
    If Not h
        h:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;oleacc&quot;,&quot;Ptr&quot;)
    If DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, &quot;Int64&quot;, x&amp;0xFFFFFFFF|y&lt;&lt;32, &quot;Ptr*&quot;, pacc)=0
        pacc := ComObjEnwrap(9,pacc,1) 
    If DllCall(&quot;oleacc\WindowFromAccessibleObject&quot;, &quot;Ptr&quot;, IsObject(pacc)?ComObjValue(pacc):pacc, &quot;Ptr*&quot;, hWnd)=0
        Return    hWnd
}

</code></pre></div><p>АП:<br />Исправил код в 4 посте.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 11:56:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76268#p76268</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76264#p76264</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>К сожалению не смог запустить</p></blockquote></div><p>Правильно, так должно работать:<br /></p><div class="codebox"><pre><code>
SetFormat, IntegerFast, h

loop  
    ToolTip % Acc_WindowFromObject2(Acc_ObjectFromPoint2()) 
 
Acc_ObjectFromPoint2()
{
    Acc_Init2()
    If    DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, &quot;Int64&quot;, x==&quot;&quot;||y==&quot;&quot;?0*DllCall(&quot;GetCursorPos&quot;,&quot;Int64*&quot;,pt)+pt:x&amp;0xFFFFFFFF|y&lt;&lt;32, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
    Return    ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

Acc_WindowFromObject2(pacc)
{
    If DllCall(&quot;oleacc\WindowFromAccessibleObject&quot;, &quot;Ptr&quot;, IsObject(pacc)?ComObjValue(pacc):pacc, &quot;Ptr*&quot;, hWnd)=0
    Return    hWnd
}

Acc_Init2()
{
    Static    h
    If Not    h
        h:=DllCall(&quot;LoadLibrary&quot;,&quot;Str&quot;,&quot;oleacc&quot;,&quot;Ptr&quot;)
}

</code></pre></div><div class="quotebox"><blockquote><p>Это скопипастено так, без пробелов?</p></blockquote></div><p>Да из библиотеки Acc.<br /></p><div class="quotebox"><blockquote><p>а проще метода нету?</p></blockquote></div><p>Пока в голову не пришло.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 11:44:46 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76264#p76264</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76262#p76262</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><div class="codebox"><pre><code>IsObject(pacc)?ComObjValue(pacc):pacc</code></pre></div></blockquote></div><p>Это скопипастено так, без пробелов?<br /><strong>Acc_Init()</strong> - этой функции нет в коде...<br />К сожалению не смог запустить, а проще метода нету?</p>]]></description>
			<author><![CDATA[null@example.com (Zohann)]]></author>
			<pubDate>Mon, 21 Oct 2013 11:16:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76262#p76262</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Определить контрол по координатам]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=76259#p76259</link>
			<description><![CDATA[<div class="codebox"><pre><code>
loop 
    ToolTip %  Acc_WindowFromObject2(Acc_ObjectFromPoint2( &quot;&quot;, x = &quot;&quot;, y = &quot;&quot;)) 
  
Acc_ObjectFromPoint2(ByRef _idChild_ = &quot;&quot;, x = &quot;&quot;, y = &quot;&quot;)
{
    Acc_Init()
    If    DllCall(&quot;oleacc\AccessibleObjectFromPoint&quot;, &quot;Int64&quot;, x==&quot;&quot;||y==&quot;&quot;?0*DllCall(&quot;GetCursorPos&quot;,&quot;Int64*&quot;,pt)+pt:x&amp;0xFFFFFFFF|y&lt;&lt;32, &quot;Ptr*&quot;, pacc, &quot;Ptr&quot;, VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&amp;varChild)=0
    Return    ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,&quot;UInt&quot;)
}

Acc_WindowFromObject2(pacc)
{
    If    DllCall(&quot;oleacc\WindowFromAccessibleObject&quot;, &quot;Ptr&quot;, IsObject(pacc)?ComObjValue(pacc):pacc, &quot;Ptr*&quot;, hWnd)=0
    Return    hWnd
}

</code></pre></div><p>Acc_ObjectFromPoint2 - кормить нужными x и y относительно экрана.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 21 Oct 2013 10:54:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=76259#p76259</guid>
		</item>
	</channel>
</rss>
