<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: edit]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7213&amp;type=atom" />
	<updated>2012-05-14T21:10:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7213</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60340#p60340" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>В AHK-basic нет типа &quot;Ptr&quot; и, соответственно, переменной <em>A_PtrSize</em>.</p></blockquote></div><p>Тогда там нет ошибок <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>2012-05-14T21:10:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60340#p60340</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60339#p60339" />
			<content type="html"><![CDATA[<p>В AHK-basic нет типа &quot;Ptr&quot; и, соответственно, переменной <em>A_PtrSize</em>.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-05-14T21:01:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60339#p60339</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60338#p60338" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Не знаю, теоретически можно, но тогда уж по логике нужно будет всю переведённую справку исправлять, она ведь писана под AHK-basic. В новой тот пример <a href="http://l.autohotkey.net/docs/commands/RegisterCallback.htm">исправлен</a>.</p></blockquote></div><p>А я и не в курсе, что для AHK_L есть отдельная справка <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> . Этот пример ведь не использует никаких особенностей AHK_L и должен работать и на классической.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-05-14T20:43:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60338#p60338</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60337#p60337" />
			<content type="html"><![CDATA[<p>Не знаю, теоретически можно, но тогда уж по логике нужно будет всю переведённую справку исправлять, она ведь писана под AHK-basic. В новой тот пример <a href="http://l.autohotkey.net/docs/commands/RegisterCallback.htm">исправлен</a>.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-05-14T20:37:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60337#p60337</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60336#p60336" />
			<content type="html"><![CDATA[<p>Может имеет смысл исправить <a href="http://www.script-coding.com/AutoHotkey/RegisterCallback.html">тот пример в справке</a>? Понятно, что это перевод, но всё-таки <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>2012-05-14T20:02:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60336#p60336</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60335#p60335" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Только что проверил в XP на 32-битном интерпретаторе.</p></blockquote></div><p>Ой, извиняюсь, плохо проверил, действительно не работает! <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-05-14T19:48:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60335#p60335</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60334#p60334" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Таки <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms644898%28v=vs.85%29.aspx">есть</a>.<br /></p><div class="quotebox"><blockquote><p><strong>Note</strong>&nbsp; To write code that is compatible with both 32-bit and 64-bit versions of Windows, use SetWindowLongPtr.</p></blockquote></div></blockquote></div><p>Имеется ввиду, что в Visual Studio SetWindowLongPtr ссылается на SetWindowLong. Вот этот отрывок из заголовочного файла VS C++(я там пометил сабж):<br /></p><div class="codebox"><pre><code>#ifdef _WIN64

WINUSERAPI
LONG_PTR
WINAPI
GetWindowLongPtrA(
    __in HWND hWnd,
    __in int nIndex);
WINUSERAPI
LONG_PTR
WINAPI
GetWindowLongPtrW(
    __in HWND hWnd,
    __in int nIndex);
#ifdef UNICODE
#define GetWindowLongPtr  GetWindowLongPtrW
#else
#define GetWindowLongPtr  GetWindowLongPtrA
#endif // !UNICODE

WINUSERAPI
LONG_PTR
WINAPI
SetWindowLongPtrA(
    __in HWND hWnd,
    __in int nIndex,
    __in LONG_PTR dwNewLong);
WINUSERAPI
LONG_PTR
WINAPI
SetWindowLongPtrW(
    __in HWND hWnd,
    __in int nIndex,
    __in LONG_PTR dwNewLong);
#ifdef UNICODE
#define SetWindowLongPtr  SetWindowLongPtrW
#else
#define SetWindowLongPtr  SetWindowLongPtrA
#endif // !UNICODE

#else  /* _WIN64 */

#define GetWindowLongPtrA   GetWindowLongA  //Вот здесь экшн :)
#define GetWindowLongPtrW   GetWindowLongW
#ifdef UNICODE
#define GetWindowLongPtr  GetWindowLongPtrW
#else
#define GetWindowLongPtr  GetWindowLongPtrA
#endif // !UNICODE

#define SetWindowLongPtrA   SetWindowLongA
#define SetWindowLongPtrW   SetWindowLongW
#ifdef UNICODE
#define SetWindowLongPtr  SetWindowLongPtrW
#else
#define SetWindowLongPtr  SetWindowLongPtrA
#endif // !UNICODE

#endif /* _WIN64 */</code></pre></div><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Только что проверил в XP на 32-битном интерпретаторе.</p></blockquote></div><p>Можно глянуть на user32.dll той системы?<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>но мой на практике вполне работоспособен</p></blockquote></div><p>Не спорю, найти стуацию где бы он не сработал не так просто <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>2012-05-14T19:05:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60334#p60334</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60332#p60332" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Александр_ пишет:</cite><blockquote><p>Нет, в 32-битной версии этой функции вообще нет.</p></blockquote></div><p>Таки <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms644898%28v=vs.85%29.aspx">есть</a>.<br /></p><div class="quotebox"><blockquote><p><strong>Note</strong>&nbsp; To write code that is compatible with both 32-bit and 64-bit versions of Windows, use SetWindowLongPtr.</p></blockquote></div><p>Только что проверил в XP на 32-битном интерпретаторе.</p><p>В общем, по БОЛЬШОМУ счёту твой вариант более универсален, но мой на практике вполне работоспособен, если правильно обработать Ctrl+V:<br /></p><div class="codebox"><pre><code>Gui, Add, Edit, hwndhEdit
Gui, Show

OnMessage(0x102, &quot;WM_CHAR&quot;)
return

GuiClose:
   ExitApp

WM_CHAR(wp, lp, msg, hwnd)
{
   global hEdit
   if (hwnd != hEdit)
      return

   if (wp = 22 &amp;&amp; RegExMatch(Clipboard, &quot;i)[^\da-f]&quot;))
      Return 0
   
   if wp in 3,8,22,24,26   ; обработка Ctrl+C, Backspace, Ctrl+V, Ctrl+X, Ctrl+Z
      return
   
   Chr := Chr(wp)
   if Chr not in 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,x
      Return 0
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-05-14T18:47:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60332#p60332</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60331#p60331" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>В справке про это вот что написано:</p><div class="quotebox"><blockquote><p>Messages sent to a control (rather than being posted) are not monitored because the system routes them directly to the control behind the scenes. This is seldom an issue for system-generated messages because most of them are posted.</p></blockquote></div><p>И действительно, стоит лишь попробовать</p><div class="codebox"><pre><code>PostMessage, 0x102, 0x77, , , ahk_id%hEdit%</code></pre></div><p>как всё мониторится.</p></blockquote></div><p>Дык я это и сказал- сообщение можно отправлять контролу напрямую, минуя родительское окно. Понятно что можно и не напрямую отправлять, например передав фокус ввода и тыкнув по клавиатуре <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /> .<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>А разве нужно проверять битность интерпретатора для вызова <em>SetWindowLongPtr</em>? Она в любом варианте, вроде, работает?</p></blockquote></div><p>Нет, в 32-битной версии этой функции вообще нет.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-05-14T18:14:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60331#p60331</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60330#p60330" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Александр_ пишет:</cite><blockquote><p>Нет, тут учитываются сообщения, которые проходят через DispatchMessage главного окна. Попробуй напрямую отправить символ:<br /></p><div class="codebox"><pre><code>SendMessage, 0x102, 0x77, , , ahk_id%hEdit%</code></pre></div><p>.</p></blockquote></div><p>В справке про это вот что написано:</p><div class="quotebox"><blockquote><p>Messages sent to a control (rather than being posted) are not monitored because the system routes them directly to the control behind the scenes. This is seldom an issue for system-generated messages because most of them are posted.</p></blockquote></div><p>И действительно, стоит лишь попробовать</p><div class="codebox"><pre><code>PostMessage, 0x102, 0x77, , , ahk_id%hEdit%</code></pre></div><p>как всё мониторится.</p><p>А разве нужно проверять битность интерпретатора для вызова <em>SetWindowLongPtr</em>? Она в любом варианте, вроде, работает?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-05-14T17:52:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60330#p60330</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60327#p60327" />
			<content type="html"><![CDATA[<p>Сабклассинг- это изменение оконной процедуры окна на свою(обычно адрес старой оконной процедуры сохраняется и используется в новой). Пример есть в <a href="http://www.script-coding.com/AutoHotkey/RegisterCallback.html">справке</a>, но он кривой и не будет работать в 64-битной системе.<br /></p><div class="codebox"><pre><code>WindowProcNew := RegisterCallback(&quot;WindowProc&quot;, &quot;&quot;, 4)
Gui, Add, edit, HWNDhWnd w200
WindowProcOld := DllCall(&quot;SetWindowLong&quot; . (A_PtrSize==8?&quot;Ptr&quot;:&quot;&quot;), &quot;ptr&quot;, hWnd, &quot;int&quot;, -4, &quot;ptr&quot;, WindowProcNew, &quot;ptr&quot;)
Gui, Show
return

WindowProc(hwnd, uMsg, wParam, lParam)
{
    Critical
    global WindowProcOld
    if (uMsg==0x0102) ;WM_CHAR
    {
       if((wParam&gt;=0x30&amp;&amp;wParam&lt;=0x39)||(wParam&gt;=97&amp;&amp;wParam&lt;=102)||(wParam&gt;=65&amp;&amp;wParam&lt;=70)||(wParam==0x08)||(wParam==3)||(wParam==26)||(wParam==24)||(wParam==22)) ;0-9, a-f, A-F, VK_BACK, ctr-c, ctrl-x, ctrl-v, ctrl-z
	      return DllCall(&quot;CallWindowProcW&quot;, &quot;ptr&quot;, WindowProcOld, &quot;ptr&quot;, hwnd, &quot;uint&quot;, uMsg, &quot;ptr&quot;, wParam, &quot;ptr&quot;, lParam, &quot;ptr&quot;)
	   else
	      return 0
    }
	else if(uMsg==0x0302) ;WM_PASTE
	{
	   if(RegExMatch(Clipboard, &quot;i)^[\da-f]*$&quot;))
	      DllCall(&quot;CallWindowProcW&quot;, &quot;ptr&quot;, WindowProcOld, &quot;ptr&quot;, hwnd, &quot;uint&quot;, uMsg, &quot;ptr&quot;, wParam, &quot;ptr&quot;, lParam, &quot;ptr&quot;)
	   return 0
	}
	else if(uMsg==0x000C) ;WM_SETTEXT
	{
	   if(RegExMatch(StrGet(lParam), &quot;i)^[\da-f]*$&quot;))
	      DllCall(&quot;CallWindowProcW&quot;, &quot;ptr&quot;, WindowProcOld, &quot;ptr&quot;, hwnd, &quot;uint&quot;, uMsg, &quot;ptr&quot;, wParam, &quot;ptr&quot;, lParam, &quot;ptr&quot;)
	   return 0
	}
	return DllCall(&quot;CallWindowProcW&quot;, &quot;ptr&quot;, WindowProcOld, &quot;ptr&quot;, hwnd, &quot;uint&quot;, uMsg, &quot;ptr&quot;, wParam, &quot;ptr&quot;, lParam, &quot;ptr&quot;)
}

Esc::
GuiClose:
   ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-05-14T16:16:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60327#p60327</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60321#p60321" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>М-м-м, не совсем понял, в коде как раз учитываются сообщения, идущие непосредственно в данный контрол.</p></blockquote></div><p>Нет, тут учитываются сообщения, которые проходят через DispatchMessage главного окна. Попробуй напрямую отправить символ:<br /></p><div class="codebox"><pre><code>SendMessage, 0x102, 0x77, , , ahk_id%hEdit%</code></pre></div><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>А WM_SETTEXT и остальное — это просто вряд ли пригодится в реальности. Но приведи и свой вариант, я убегаю сейчас. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p></blockquote></div><p>Чуть позже напишу, у меня острый приступ лени сейчас <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /> .</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-05-14T13:49:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60321#p60321</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60320#p60320" />
			<content type="html"><![CDATA[<p>М-м-м, не совсем понял, в коде как раз учитываются сообщения, идущие непосредственно в данный контрол. Что до WM_PASTE, то да, нужно добавить в обработку.<br /></p><div class="codebox"><pre><code>Gui, Add, Edit, hwndhEdit
Gui, Show

OnMessage(0x102, &quot;WM_CHAR&quot;)
return

GuiClose:
   ExitApp

WM_CHAR(wp, lp, msg, hwnd)
{
   global hEdit
   if (hwnd != hEdit)
      return

   if wp in 3,8,22,24,26   ; обработка Ctrl+C, Backspace, Ctrl+V, Ctrl+X, Ctrl+Z
      return
   
   Chr := Chr(wp)
   if Chr not in 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,x
      Return 0
}</code></pre></div><p>А WM_SETTEXT и остальное — это просто вряд ли пригодится в реальности. Но приведи и свой вариант, я убегаю сейчас. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-05-14T13:28:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60320#p60320</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60316#p60316" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, не стоит так делать, поскольку сообщение может идти напрямую контролу. Нужно сабклассить, тем более, что в справке кривой пример на эту тему <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> . Кроме того стоит учесть WM_PASTE и WM_SETTEXT(возможно ещё какие-то есть), которые вообще не используют WM_CHAR.</p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2012-05-14T13:00:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60316#p60316</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: edit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=60315#p60315" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Gui, Add, Edit, hwndhEdit
Gui, Show

OnMessage(0x102, &quot;WM_CHAR&quot;)
return

GuiClose:
   ExitApp

WM_CHAR(wp, lp, msg, hwnd)
{
   global hEdit
   if (hwnd != hEdit)
      return

   if wp in 3,8,24,26   ; обработка Ctrl+C, Backspace, Ctrl+X, Ctrl+Z
      return
   
   Chr := Chr(wp)
   if Chr not in 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
      Return 0
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2012-05-14T12:42:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=60315#p60315</id>
		</entry>
</feed>
