<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Отследить перемещение GUI]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17144&amp;type=atom" />
	<updated>2022-05-27T17:04:00Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17144</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153365#p153365" />
			<content type="html"><![CDATA[<p>Это отличный ответ, спасибо.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-27T17:04:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153365#p153365</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153364#p153364" />
			<content type="html"><![CDATA[<p>Вот написал пример для всего сразу:<br /></p><div class="codebox"><pre><code>global exStyles := (WS_EX_COMPOSITED := 0x2000000) | (WS_EX_LAYERED := 0x80000)
     , WM_MOVE   := 0x0003
     , WM_MOVING := 0x0216
     , WS_VSCROLL := 0x00200000

Gui, New, +hwndhGui +E%exStyles%, Window position tracking
Gui, Margin, 20, 20
Gui, Font, s11, Calibri
Gui, Add, Text, w120 Right, WM_MOVE`nClient area position
Gui, Add, Edit, x+5 yp-4 w110 r2 -%WS_VSCROLL%

Gui, Add, Text, xm y+15 w120 Right, WM_MOVING`nWindow position
Gui, Add, Edit, x+5 yp-4 w110 r4 -%WS_VSCROLL%
GuiControl, Focus, Static1
Gui, Show

OnMove := Func(&quot;OnGuiMove&quot;).Bind(hGui)
OnMessage(WM_MOVE  , OnMove)
OnMessage(WM_MOVING, OnMove)

OnGuiMove(hGui, wp, lp, msg, hwnd) {
   if (hGui != hwnd)
      Return
   
   Switch msg {
      case WM_MOVE   : GuiControl,, Edit1, % &quot;x:&quot; . A_Tab . lp &amp; 0xFFFF . &quot;`n&quot;
                                           . &quot;y:&quot; . A_Tab . lp &gt;&gt; 16
                                           
      case WM_MOVING : GuiControl,, Edit2, % &quot;left:&quot;   . A_Tab . NumGet(lp +  0, &quot;Int&quot;) . &quot;`n&quot;
                                           . &quot;top:&quot;    . A_Tab . NumGet(lp +  4, &quot;Int&quot;) . &quot;`n&quot;
                                           . &quot;right:&quot;  . A_Tab . NumGet(lp +  8, &quot;Int&quot;) . &quot;`n&quot;
                                           . &quot;bottom:&quot; . A_Tab . NumGet(lp + 12, &quot;Int&quot;)
   }
}

GuiClose() {
   ExitApp
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-05-27T16:50:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153364#p153364</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153363#p153363" />
			<content type="html"><![CDATA[<p>Хорошо, я использовал WM_MOVING, оно срабатывает как мне нужно. Но как теперь вытащить из lParam нужные мне позиции?</p><div class="quotebox"><blockquote><p>lParam <br />A pointer to a RECT structure with the current position of the window, in screen coordinates. To change the position of the drag rectangle, an application must change the members of this structure.</p></blockquote></div><div class="codebox"><pre><code>typedef struct _RECT {
  LONG left;
  LONG top;
  LONG right;
  LONG bottom;
} RECT, *PRECT;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-27T16:47:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153363#p153363</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153362#p153362" />
			<content type="html"><![CDATA[<p>Добавляйте OnMessage после показа окна. WM_MOVE отслеживает положение клиентской области окна. Для отслеживания положения внешней рамки окна есть <a href="https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-moving">WM_MOVING</a>.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-05-27T16:41:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153362#p153362</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153361#p153361" />
			<content type="html"><![CDATA[<p>И я тут выяснил, что координаты можно узнать таким способом:<br /></p><div class="codebox"><pre><code>WM_MOVE(wParam, lParam)
{
	static init := OnMessage(0x3, &quot;WM_MOVE&quot;)
	static callCount := 0

	if (callCount &lt; 3)
	{
		callCount++
		return
	}

	x := lParam &amp; 0xFFFF
	y := lParam &gt;&gt; 16

	ToolTip, % x &quot; &quot; y
}</code></pre></div><p>Вот только как мне избавиться от срабатывания при инициализации.. Нормальным способом, а не тот, что я использовал.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-27T16:34:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153361#p153361</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153360#p153360" />
			<content type="html"><![CDATA[<p>Но вопрос то все же в том, как оно определяет на какое именно окно реагировать?</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-27T16:24:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153360#p153360</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153359#p153359" />
			<content type="html"><![CDATA[<p>Хех, лишнее удаляя и его удалил, но работает и без него.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-05-27T16:23:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153359#p153359</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153358#p153358" />
			<content type="html"><![CDATA[<p>А где собственно используется этот хэндл в данном примере?</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-27T16:19:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153358#p153358</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153357#p153357" />
			<content type="html"><![CDATA[<p>Для этого каждому окну свой хэндл установить, в примере это есть.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-05-27T16:16:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153357#p153357</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153356#p153356" />
			<content type="html"><![CDATA[<p>Вчера разбирался с &quot;OnMessage&quot;, перетаскивание на лкм есть, но хотелось еще выводить контекстное меню по пкм, и вот вопрос возник.. А как оно узнает, у какого окна оно ловит &quot;события&quot;?</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-27T16:13:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153356#p153356</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153355#p153355" />
			<content type="html"><![CDATA[<p>Можно например так:</p><div class="codebox"><pre><code>Gui +LastFound +AlwaysOnTop +ToolWindow +hwndhGui
Gui Color, 0xDDFFAA
Gui Add, Text, vText x8 y8 w150 h23
Gui Show
WM_MOVE()
OnMessage(0x3, &quot;WM_MOVE&quot;)   ; Отслеживаем перемещения окна.
Return

GuiEscape:
GuiClose:
ExitApp

WM_MOVE(){
 global
 WinGetPos, x, y
 GuiControl,, Text, % &quot;Позиция: X: &quot; x &quot;,  Y: &quot; y
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-05-27T16:03:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153355#p153355</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153354#p153354" />
			<content type="html"><![CDATA[<p>Похожая тема: <a href="https://forum.script-coding.com/viewtopic.php?id=5553">AHK: Оконтуривание рамки активного окна</a>.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2022-05-27T16:03:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153354#p153354</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153353#p153353" />
			<content type="html"><![CDATA[<p>Допустим сам пользователь.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-27T15:38:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153353#p153353</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153352#p153352" />
			<content type="html"><![CDATA[<p>Перемещение происходит самим скриптом или его положение меняет другая программа?</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-05-27T15:37:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153352#p153352</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Отследить перемещение GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153349#p153349" />
			<content type="html"><![CDATA[<p>Можно ли как-то нормальный способом аля &quot;хук&quot;, отследить перемещение окна GUI?</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-05-26T23:35:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153349#p153349</id>
		</entry>
</feed>
