<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: MsgBox - положение окна на экране]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6424&amp;type=atom" />
	<updated>2011-11-21T10:57:40Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6424</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53744#p53744" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Александр_ пишет:</cite><blockquote><p>Нужно поставить локальный хук на WH_CBT...</p></blockquote></div><p>Спасибо, логично.<br /></p><div class="quotebox"><cite>Александр_ пишет:</cite><blockquote><p>Лучше всё-таки своё окно сделать <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p></blockquote></div><p>Мне тоже показалось, что проще.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2011-11-21T10:57:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53744#p53744</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53726#p53726" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Получается, что FindWindow() находит окно раньше, чем оно появляется на экране, в отличие от WinExist()?</p></blockquote></div><p>Как повезёт. Если успеет отработать в промежутке между созданием окна и вызовом ShowWindow, то прокатит <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> .<br />Ну вообще не хорошо таймерами кидаться- не надёжно и систему напрягает. Нужно поставить локальный хук на WH_CBT и обрабатывать код LPCBT_CREATEWND. В lParam будет ссылка на структуру CBT_CREATEWND, в которой будет ссылка структуру CREATESTRUCT, в которой будут данные о положении окна, которые можно подменить. Ссылка на имя класса в этой структуре скорее всего будет невалидной, это отмечено в документации, поэтому нужно его отдельно получать.<br /></p><div class="codebox"><pre><code>hhook:=DllCall(&quot;SetWindowsHookEx&quot;, &quot;int&quot;, 5, &quot;uint&quot;, RegisterCallback(&quot;HookProc&quot;, &quot;&quot;, 3), &quot;uint&quot;, 0, &quot;uint&quot;, DllCall(&quot;GetCurrentThreadId&quot;, &quot;uint&quot;), &quot;uint&quot;)
msgbox 111111111111111
msgbox 222222222222222
DllCall(&quot;UnhookWindowsHookEx&quot;, &quot;uint&quot;, hhook)
ExitApp
return

HookProc(code,wParam,lParam)
{
	if (code=3) ;если создаётся создаётся
	{
	   VarSetCapacity(Class, 14, 0) ; память под имя класса окна
	   DllCall(&quot;GetClassName&quot;, &quot;uint&quot;, wParam, &quot;uint&quot;, &amp;Class, &quot;uint&quot;, 7) ;получаем имя класса
	   ClassName:=StrGet(&amp;Class, 6) ;можно длину не указывать, строка с нулём на конце
	   if (ClassName=&quot;#32770&quot;) ;если MessageBox
	   {
	      NumPut(0,NumGet(lParam|0), 24) ;игрек
		  NumPut(0,NumGet(lParam|0), 28) ;икс
	   }
	}
	return DllCall(&quot;CallNextHookEx&quot;, &quot;uint&quot;, hhook, &quot;uint&quot;, code, &quot;uint&quot;, wParam, &quot;uint&quot;, lParam)
}</code></pre></div><p>P.S. Лучше всё-таки своё окно сделать <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-11-20T23:47:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53726#p53726</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53704#p53704" />
			<content type="html"><![CDATA[<p>Хотя и просто так получается:<br /></p><div class="codebox"><pre><code>SetTimer, ChangePos, 1
MsgBox,, Заголовок, Текст
Return

ChangePos:
   DetectHiddenWindows, On
   if !hMsgBox := WinExist(&quot;Заголовок ahk_class #32770&quot;)
      Return
      
   WinMove, ahk_id %hMsgBox%,, 100, 100
   SetTimer, ChangePos, Off
   Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2011-11-20T10:49:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53704#p53704</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53702#p53702" />
			<content type="html"><![CDATA[<p>Спасибо, интересно! <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Только заголовок у него не появился.<br />То-есть, просто сменить позицию можно так:</p><div class="codebox"><pre><code>SetTimer, ChangePos, 1
MsgBox,, Заголовок, Текст
Return

ChangePos:
   if !hMsgBox:=DllCall(&quot;FindWindow&quot;, Str, &quot;#32770&quot;, Str, &quot;Заголовок&quot;)
      Return
      
   DllCall(&quot;SetWindowPos&quot;, UInt, hMsgBox, UInt, 0, Int, 100, Int, 100, Int, 0, Int, 0, UInt, SWP_NOSIZE := 1)
   SetTimer, ChangePos, Off
   Return</code></pre></div><p>Получается, что <em>FindWindow()</em> находит окно раньше, чем оно появляется на экране, в отличие от <em>WinExist()</em>?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2011-11-20T10:09:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53702#p53702</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53688#p53688" />
			<content type="html"><![CDATA[<p>Немного баловства <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />:</p><div class="codebox"><pre><code>#NoTrayIcon
SetBatchLines, -1
Str:=&quot;Бегущая строка... &quot;
StrLenght:=StrLen(Str)
SetTimer, ChangeMsgBox, 1
MsgBox,0x40004,Видоизменённый MsgBox,
SetTimer, ScrollText,Off
ExitApp

ChangeMsgBox:
if !(hMsgBox:=DllCall(&quot;FindWindow&quot;,&quot;str&quot;,&quot;#32770&quot;,&quot;str&quot;,&quot;Видоизменённый MsgBox&quot;))
return
SetTimer, ChangeMsgBox, Off
DllCall(&quot;SetWindowLong&quot;,&quot;uint&quot;,hMsgBox,&quot;int&quot;,-20,&quot;uint&quot;,DllCall(&quot;GetWindowLong&quot;,&quot;uint&quot;,hMsgBox,&quot;int&quot;,-20)|WS_EX_TOOLWINDOW:=0x80) ; ???
DllCall(&quot;SetWindowLong&quot;,&quot;uint&quot;,hMsgBox,&quot;int&quot;,-16,&quot;uint&quot;,DllCall(&quot;GetWindowLong&quot;,&quot;uint&quot;,hMsgBox,&quot;int&quot;,-16)^WS_CAPTION:=0xC00000)
DllCall(&quot;SetWindowPos&quot;,&quot;uint&quot;,hMsgBox,&quot;uint&quot;,0,&quot;int&quot;,A_ScreenWidth/3,&quot;int&quot;,A_ScreenHeight/2-120,&quot;int&quot;,A_ScreenWidth/3,&quot;int&quot;,240,&quot;uint&quot;,0x40)
ControlGet, hbt1, Hwnd,,Button1, ahk_id %hMsgBox%
ControlGet, hbt2, Hwnd,,Button2, ahk_id %hMsgBox%
DllCall(&quot;SetWindowPos&quot;,&quot;uint&quot;,hbt1,&quot;uint&quot;,0,&quot;int&quot;,-3,&quot;int&quot;,208-3,&quot;int&quot;,A_ScreenWidth/6,&quot;int&quot;,30,&quot;uint&quot;,0x40)
DllCall(&quot;SetWindowPos&quot;,&quot;uint&quot;,hbt2,&quot;uint&quot;,0,&quot;int&quot;,A_ScreenWidth/6-3,&quot;int&quot;,208-3,&quot;int&quot;,A_ScreenWidth/6,&quot;int&quot;,30,&quot;uint&quot;,0x40)
SetTimer, ScrollText,250
Return

ScrollText:
StartPos += StartPos&lt;StrLenght ? 1 : -StrLenght+1
ScrlText:=SubStr(Str,StartPos) . SubStr(Str,1,StartPos)
DllCall(&quot;SendMessage&quot;,&quot;uint&quot;,hbt2,&quot;uint&quot;,0xC,&quot;uint&quot;,0,&quot;uint&quot;,&amp;ScrlText)
Return

/*
SWP_SHOWWINDOW   = 0x40
WM_SETTEXT       = 0xC
*/</code></pre></div>]]></content>
			<author>
				<name><![CDATA[kirtech]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26525</uri>
			</author>
			<updated>2011-11-19T17:10:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53688#p53688</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53398#p53398" />
			<content type="html"><![CDATA[<p>Ясно, спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Bobby]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25841</uri>
			</author>
			<updated>2011-11-10T08:42:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53398#p53398</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53397#p53397" />
			<content type="html"><![CDATA[<p>Посредством AHK — никак, но можно создать своё окно вместо MsgBox.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2011-11-10T08:26:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53397#p53397</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: MsgBox - положение окна на экране]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=53389#p53389" />
			<content type="html"><![CDATA[<p>Есть ли способ вывода окна сообщения MsgBox не в центре, как по умолчанию, а в нужном месте?<br />&nbsp; &nbsp; &nbsp;Можно, конечно, переместить окно по команде WinMove, но хотелось бы, чтобы окно появлялось сразу в нужном месте.</p>]]></content>
			<author>
				<name><![CDATA[Bobby]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25841</uri>
			</author>
			<updated>2011-11-10T04:51:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=53389#p53389</id>
		</entry>
</feed>
