<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=10307&amp;type=atom" />
	<updated>2015-01-06T14:55:27Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=10307</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90067#p90067" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>чтобы достаточно было передать в качестве параметра хэндл edit-контрола</p></blockquote></div><p>А Gui как создавать? Имя ведь совпасть может с используемым в скрипте.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-01-06T14:55:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90067#p90067</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90066#p90066" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Это плюс в том случае, если он нужен, а иногда требуется, например, найти последнее вхождение какого-либо слова. Изначально-то цель была повторить поведение виндосовского поиска, а там цикличности нет.</p></blockquote></div><p>Сначала повторить, а потом найти возможности допилить каждому под себя, на цикличность можно и флажок добавить.<br /></p><div class="codebox"><pre><code>#SingleInstance Force
#NoEnv
StringCaseSense Locale

ES_NOHIDESEL := 256  ; показывает выделение текста в Edit при неактивном окне
EM_SETSEL := 0x00B1  ; установка выделения
EM_SCROLLCARET := 0xB7  ; сделать видимым выделенный текст
EM_GETSEL := 0xB0  ; извлечь позицию каретки ввода
VarSetCapacity(start, 4), VarSetCapacity(end, 4)

Loop 12
    Text .= &quot;Как можно сделать поиск в поле Edit?`n&quot;

Gui, -DPIScale +HWNDhGUIMain
Gui, Add, Edit, x0 y0 w500 h100 vMainEdit hwndhMainEdit %ES_NOHIDESEL%, %Text%
SendMessage, EM_SETSEL, 0, 0, , ahk_id %hMainEdit%
Gui, Show, w500 h300, Edit find

Gui, 2: +Owner1 -MaximizeBox -MinimizeBox -DPIScale +HWNDhGUIFind
Gui, 2: Add, Text, ym+5, Что:
Gui, 2: Add, Edit, x+25 yp-5 w284 vFind hwndhFind, Можно
Gui, 2: Add, Button, x+10 yp gGoSearch, Найти далее
Gui, 2: Add, Button, xp y+5 wp gCancel, Отмена
Gui, 2: Add, Checkbox, vLoop y+0 xm Checked, Зациклить поиск
Gui, 2: Add, Checkbox, vSens y+10 xp, С учетом регистра
Gui, 2: Add, GroupBox, x+10 yp-35 h55, Направление
Gui, 2: Add, Radio, xp+10 yp+25 vDirectUp, Вверх
Gui, 2: Add, Radio, x+15 Checked, Вниз 

SearchEdit: 
    Gui, 2: Show, , Найти 
    Return
    
Cancel:
    Gui, 2: Hide
    Return

GoSearch:
    GuiControlGet, DirectUp, 2:
    GuiControlGet, Sens, 2:
    GuiControlGet, Loop, 2:
    ControlGetText, MainEdit,, ahk_id %hMainEdit%
    ControlGetText, Find,, ahk_id %hFind%
    SendMessage, EM_GETSEL, &amp;start, &amp;end, , ahk_id %hMainEdit%
    If DirectUp
        f := (f := InStr(SubStr(MainEdit, 1, NumGet(start)), Find, Sens, 0)) ? f : (Loop ? InStr(MainEdit, Find, Sens, 0) : 0)
    Else
        f := (f := InStr(MainEdit, Find, Sens, NumGet(end)+1)) ? f : (Loop ? InStr(MainEdit, Find, Sens, 1) : 0)
    If !f
    {
        MsgBox, 8256, Edit find, Не удаётся найти &quot;%Find%&quot;
        Return
    }
    SendMessage, EM_SETSEL, f-1, f+StrLen(Find)-1, , ahk_id %hMainEdit%
    SendMessage, EM_SCROLLCARET,,,, ahk_id %hMainEdit%
    Return

#If WinActive(&quot;ahk_id&quot; hGUIMain)
F3:: GoSub GoSearch
^vk46:: GoSub SearchEdit   ;  &quot;Ctrl+F&quot;
#If WinActive(&quot;ahk_id&quot; hGUIFind)
Enter:: GoSub GoSearch
#If

GuiEscape:
GuiClose:
    ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-01-06T14:53:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90066#p90066</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90065#p90065" />
			<content type="html"><![CDATA[<p>Не имею ничего против. Теперь для Коллекции нужно привести к функциональному виду по возможности без глобальных переменных, чтобы достаточно было передать в качестве параметра хэндл edit-контрола. Ну и Find-Replace вариант туда присобачить было бы неплохо. У меня пока времени нет. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-01-06T14:46:40Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90065#p90065</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90056#p90056" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Так что, думаю, без разницы.</p></blockquote></div><p>Тогда разумно сделать, как говорят разработчики. Я ведь об этом и написал: если нет явной нужды, то не стоит оригинальничать. Ведь любые наши рассуждения по большому счёту догадки.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-06T13:46:53Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90056#p90056</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90052#p90052" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Зато есть плюс, например зацикленный поиск.</p></blockquote></div><p>Это плюс в том случае, если он нужен, а иногда требуется, например, найти последнее вхождение какого-либо слова. Изначально-то цель была повторить поведение виндосовского поиска, а там цикличности нет.</p><div class="quotebox"><cite>YMP пишет:</cite><blockquote><p>А почему EM_SETSEL и EM_SCROLLCARET через PostMessage посылаете? Есть какой-то скрытый смысл?</p></blockquote></div><p>Более-менее понятно, почему разработчики Windows предлагают отправлять эти сообщения с помощью SendMessage: на их выполнение требуется какое-то время и окно не будет отзываться, пока они выполняются, и если предполагается, что за ними нужно обработать ещё много других сообщений, код может сильно «обогнать» окно. В данном же случае их всего два подряд, и проблем не возникает. Так что, думаю, без разницы.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-01-06T13:21:19Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90052#p90052</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90027#p90027" />
			<content type="html"><![CDATA[<p>Думаю, что можно на это ориентироваться. Это у нас одно слово &quot;послать&quot; используется, а у них два — send и post. Два варианта посылки сообщений. Отсюда и две функции.</p><p>Ну, а явное указание, как я уже говорил, в документации к Windows SDK.<br /></p><div class="codebox"><pre><code>
To send this message, call the SendMessage function as follows. 

lResult = SendMessage(      // returns LRESULT in lResult
   (HWND) hWndControl,      // handle to destination control
   (UINT) EM_SETSEL,        // message ID
   (WPARAM) wParam,         // = (WPARAM) () wParam;
   (LPARAM) lParam          // = (LPARAM) () lParam; );  
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-06T07:25:26Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90027#p90027</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90026#p90026" />
			<content type="html"><![CDATA[<p>Не пойму где тут <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb761637(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library … s.85).aspx</a> явные рекомендации разработчиков использовать именно SendMessage? Только во фразе - &quot;You can send this message&quot;? Как то неоднозначно.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-01-06T06:44:37Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90026#p90026</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90025#p90025" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Я отталкиваюсь от описания AutoHotkey, если ненужен код возврата, то использую PostMessage. На практике, в некоторых случаях существенно ускоряет выполнение.</p></blockquote></div><p>Думаю, что без явной нужды нарушать рекомендации разработчиков не стоит. А это всё-таки Microsoft, а не авторы AutoHotkey.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-06T06:34:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90025#p90025</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90024#p90024" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Но в твоём коде один минус. При нажатии F3, если окно поиска уже вызывалось ранее, оно не должно появляться снова, а просто поиск и выделение продолжается по указанным прежде данным.</p></blockquote></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Ну это просто:</div><div class="fancy_spoiler"><div class="codebox"><pre><code>
#SingleInstance Force
#NoEnv
StringCaseSense Locale

ES_NOHIDESEL := 256  ; показывает выделение текста в Edit при неактивном окне
EM_SETSEL := 0x00B1  ; установка выделения
EM_SCROLLCARET := 0xB7  ; сделать видимым выделенный текст
EM_GETSEL := 0xB0  ; извлечь позицию каретки ввода
VarSetCapacity(start, 4), VarSetCapacity(end, 4)

Loop 12
    Text .= &quot;Как можно сделать поиск в поле Edit?`n&quot;

Gui, -DPIScale +HWNDhGUIMain
Gui, Add, Edit, x0 y0 w500 h100 vMainEdit hwndhMainEdit %ES_NOHIDESEL%, %Text%
PostMessage, EM_SETSEL, 0, 0, , ahk_id %hMainEdit%
Gui, Show, w500 h300, Edit find

Gui, 2: +Owner1 -MaximizeBox -MinimizeBox -DPIScale +HWNDhGUIFind
Gui, 2: Add, Text, ym+5, Что:
Gui, 2: Add, Edit, x+25 yp-5 w284 vFind hwndhFind, Можно
Gui, 2: Add, Button, x+10 yp gGoSearch, Найти далее
Gui, 2: Add, Button, xp y+5 wp gCancel, Отмена
Gui, 2: Add, Checkbox, vSens y+0 xm, С учетом регистра
Gui, 2: Add, GroupBox, x+10 yp-25 h50, Направление
Gui, 2: Add, Radio, xp+10 yp+25 vDirectUp, Вверх
Gui, 2: Add, Radio, x+15 Checked, Вниз 

SearchEdit: 
    Gui, 2: Show, , Найти 
    Return
    
Cancel:
    Gui, 2: Hide
    Return

GoSearch:
    GuiControlGet, DirectUp, 2:
    GuiControlGet, Sens, 2:
    ControlGetText, MainEdit,, ahk_id %hMainEdit%
    ControlGetText, Find,, ahk_id %hFind%
    SendMessage, EM_GETSEL, &amp;start, &amp;end, , ahk_id %hMainEdit%
    If DirectUp
        f := (f := InStr(SubStr(MainEdit, 1, NumGet(start)), Find, Sens, 0)) ? f : InStr(MainEdit, Find, Sens, 0)
    Else
        f := (f := InStr(MainEdit, Find, Sens, NumGet(end)+1)) ? f : InStr(MainEdit, Find, Sens, 1)
    If !f
    {
        MsgBox, 8256, Edit find, Не удаётся найти &quot;%Find%&quot;
        Return
    }
    PostMessage, EM_SETSEL, f-1, f+StrLen(Find)-1, , ahk_id %hMainEdit%
    PostMessage, EM_SCROLLCARET,,,, ahk_id %hMainEdit%
    Return

#If WinActive(&quot;ahk_id&quot; hGUIMain)
F3:: GoSub GoSearch
^vk46:: GoSub SearchEdit   ;  &quot;Ctrl+F&quot;
#If WinActive(&quot;ahk_id&quot; hGUIFind)
Enter:: GoSub GoSearch
#If

GuiEscape:
GuiClose:
    ExitApp
</code></pre></div></div></div><p>Зато есть плюс, например зацикленный поиск.<br /></p><div class="quotebox"><blockquote><p>Ради интереса сделал нативный вариант:</p></blockquote></div><p>Очень любопытно, значит это окно из API.<br /></p><div class="quotebox"><cite>YMP пишет:</cite><blockquote><p>А почему EM_SETSEL и EM_SCROLLCARET через PostMessage посылаете? Есть какой-то скрытый смысл?</p></blockquote></div><p>Я отталкиваюсь от описания AutoHotkey, если ненужен код возврата, то использую PostMessage. На практике, в некоторых случаях существенно ускоряет выполнение.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-01-06T06:26:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90024#p90024</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90021#p90021" />
			<content type="html"><![CDATA[<p>А почему EM_SETSEL и EM_SCROLLCARET через PostMessage посылаете? Есть какой-то скрытый смысл? В MSDN они с SendMessage описаны.</p><p>Точнее, нет, это я в документации к Windows SDK видел. А в MSDN, видимо, остаётся ориентироваться на слово send в описании.<br /></p><div class="quotebox"><blockquote><p>You can send this message to either an edit control or a rich edit control.</p></blockquote></div><p>Иначе там будет post.<br /></p><div class="quotebox"><blockquote><p>Posted to the window with the focus when the user chooses a new input language,</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-06T04:31:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90021#p90021</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90017#p90017" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Насколько я знаю, тут &quot;StringCaseSense Locale&quot; хватит вполне.</p></blockquote></div><p>Да, точно, забыл про него.<br />Но в твоём коде один минус. При нажатии F3, если окно поиска уже вызывалось ранее, оно не должно появляться снова, а просто поиск и выделение продолжается по указанным прежде данным.<br />Ради интереса сделал нативный вариант:<br /></p><div class="codebox"><pre><code>global FR_DOWN := 0x1, FR_MATCHCASE := 0x4, EM_SETSEL := 0xB1
ES_NOHIDESEL := 256
StringCaseSense, Locale

Loop 24
   text .= &quot;Съешь же ещё этих мягких французских булок, да выпей чаю`r`n&quot;

Gui, +hwndhGui
Gui, Add, Edit, hwndhEdit w400 h200 %ES_NOHIDESEL%, % text
PostMessage, EM_SETSEL, 0, 0,, ahk_id %hEdit%
Gui, Show
OnMessage(DllCall(&quot;RegisterWindowMessage&quot;, Str, &quot;commdlg_FindReplace&quot;), &quot;FindTextDlg&quot;)
Return

GuiClose:
GuiEscape:
   ExitApp

#If WinActive(&quot;ahk_id&quot; hGui)
^vk46::   ; Ctrl + F
   oFind := FindTextDlgInit(hGui)
   Return
   
F3::
   if oFind.hDlg
      Return
   
   if pDATA := oFind.pDATA
      flags := NumGet(pDATA + A_PtrSize*3, &quot;UInt&quot;)
      , FindHandling(StrGet(NumGet(pDATA + A_PtrSize*4)), flags &amp; FR_DOWN, flags &amp; FR_MATCHCASE)
   else
      oFind := FindTextDlgInit(hGui)
   Return
   
FindTextDlgInit(hGui)
{
   static FINDREPLACE, FindWhat, FR_DOWN := 1, FR_HIDEWHOLEWORD := 0x10000

   if !FINDREPLACE  {
      FindWhatLen := A_IsUnicode ? 160 : 80
      VarSetCapacity(FINDREPLACE, SizeOfFR := A_PtrSize*10)
      VarSetCapacity(FindWhat, FindWhatLen)

      NumPut(SizeOfFR, FINDREPLACE, &quot;UInt&quot;)
      NumPut(hGui, &amp;FINDREPLACE + A_PtrSize)
      NumPut(FR_DOWN | FR_HIDEWHOLEWORD, &amp;FINDREPLACE + A_PtrSize*3, &quot;UInt&quot;)
      NumPut(&amp;FindWhat, &amp;FINDREPLACE + A_PtrSize*4)
      NumPut(FindWhatLen, &amp;FINDREPLACE + A_PtrSize*6, &quot;UShort&quot;)
   }
   Return {hDlg: DllCall(&quot;Comdlg32\FindText&quot;, Ptr, &amp;FINDREPLACE, Ptr), pDATA: &amp;FINDREPLACE}
}

FindTextDlg(wp, lp)
{
   global oFind
   static FR_FINDNEXT := 0x8, FR_DIALOGTERM := 0x40
   flags := NumGet(lp + A_PtrSize*3, &quot;UInt&quot;)
   
   if flags &amp; FR_FINDNEXT
      FindHandling(StrGet(NumGet(lp + A_PtrSize*4)), flags &amp; FR_DOWN, flags &amp; FR_MATCHCASE)
   
   if flags &amp; FR_DIALOGTERM
      oFind.hDlg := 0
}

FindHandling(text, down, case)
{
   global hEdit, oFind
   static EM_GETSEL := 0xB0, EM_SCROLLCARET := 0xB7, MB_ICONINFORMATION := 0x40, MB_TASKMODAL := 0x2000
   
   WinExist(&quot;ahk_id&quot; hEdit)
   ControlGetText, EditText
   SendMessage, EM_GETSEL
   start := ErrorLevel &amp; 0xFFFF, end := ErrorLevel &gt;&gt; 16
   if ! pos := InStr(down ? EditText : SubStr(EditText, 1, start), text, case, down ? end + 1 : 0)
      Return DllCall(&quot;MessageBox&quot;, Ptr, (h := oFind.hDlg) ? h : hEdit
                                 , Str, &quot;Не удаётся найти &quot;&quot;&quot; . text . &quot;&quot;&quot;&quot;
                                 , Str, &quot;Find&quot;
                                 , UInt, MB_ICONINFORMATION | MB_TASKMODAL)
   
   PostMessage, EM_SETSEL, pos - 1, pos - 1 + StrLen(text)
   PostMessage, EM_SCROLLCARET
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-01-06T00:49:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90017#p90017</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90016#p90016" />
			<content type="html"><![CDATA[<p>С иконкой ничего не нашёл.<br /></p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>По-моему, сыровато для Коллекции. Регистр кириллицы вполне можно учесть через RegEx. Кроме того, Msgbox «Не найдено» перекрывается окном поиска.</p></blockquote></div><p>RegEx думаю тяжелый получится с нахождением правых совпадений при поиске вверх. Насколько я знаю, тут &quot;StringCaseSense Locale&quot; хватит вполне. Msgbox подукрасил.<br /></p><div class="codebox"><pre><code>
#SingleInstance Force
#NoEnv
StringCaseSense Locale

ES_NOHIDESEL := 256  ; показывает выделение текста в Edit при неактивном окне
EM_SETSEL := 0x00B1  ; установка выделения
EM_SCROLLCARET := 0xB7  ; сделать видимым выделенный текст
EM_GETSEL := 0xB0  ; извлечь позицию каретки ввода
VarSetCapacity(start, 4), VarSetCapacity(end, 4)

Loop 12
    Text .= &quot;Как можно сделать поиск в поле Edit?`n&quot;

Gui, -DPIScale +HWNDhGUIMain
Gui, Add, Edit, x0 y0 w500 h100 vMainEdit hwndhMainEdit %ES_NOHIDESEL%, %Text%
PostMessage, EM_SETSEL, 0, 0, , ahk_id %hMainEdit%
Gui, Show, w500 h300, Edit find

Gui, 2: +Owner1 -MaximizeBox -MinimizeBox -DPIScale +HWNDhGUIFind
Gui, 2: Add, Text, ym+5, Что:
Gui, 2: Add, Edit, x+25 yp-5 w284 vFind hwndhFind, Можно
Gui, 2: Add, Button, x+10 yp gGoSearch, Найти далее
Gui, 2: Add, Button, xp y+5 wp gCancel, Отмена
Gui, 2: Add, Checkbox, vSens y+0 xm, С учетом регистра
Gui, 2: Add, GroupBox, x+10 yp-25 h50, Направление
Gui, 2: Add, Radio, xp+10 yp+25 vDirectUp, Вверх
Gui, 2: Add, Radio, x+15 Checked, Вниз 

SearchEdit: 
    Gui, 2: Show, , Найти
    Return
    
Cancel:
    Gui, 2: Hide
    Return

GoSearch:
    GuiControlGet, DirectUp, 2:
    GuiControlGet, Sens, 2:
    ControlGetText, MainEdit,, ahk_id %hMainEdit%
    ControlGetText, Find,, ahk_id %hFind%
    SendMessage, EM_GETSEL, &amp;start, &amp;end, , ahk_id %hMainEdit%
    If DirectUp
        f := (f := InStr(SubStr(MainEdit, 1, NumGet(start)), Find, Sens, 0)) ? f : InStr(MainEdit, Find, Sens, 0)
    Else
        f := (f := InStr(MainEdit, Find, Sens, NumGet(end)+1)) ? f : InStr(MainEdit, Find, Sens, 1)
    If !f
    {
        MsgBox, 8256, Edit find, Не удаётся найти &quot;%Find%&quot;
        Return
    }
    PostMessage, EM_SETSEL, f-1, f+StrLen(Find)-1, , ahk_id %hMainEdit%
    PostMessage, EM_SCROLLCARET,,,, ahk_id %hMainEdit%
    Return

#If WinActive(&quot;ahk_id&quot; hGUIMain)
F3::
^vk46:: GoSub SearchEdit   ;  &quot;Ctrl+F&quot;
#If WinActive(&quot;ahk_id&quot; hGUIFind)
Enter:: GoSub GoSearch
#If

GuiEscape:
GuiClose:
    ExitApp
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-01-05T23:34:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90016#p90016</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90013#p90013" />
			<content type="html"><![CDATA[<p>Попробовал найти слово &quot;Сделать&quot; без учета регистра - не нашло, а вот слово &quot;сделать&quot; нашло.</p>]]></content>
			<author>
				<name><![CDATA[sergeiplugatyr]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=30382</uri>
			</author>
			<updated>2015-01-05T21:08:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90013#p90013</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90010#p90010" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>если посылать WM_SETICON с нулевым хендлом, но не срабатывает.</p></blockquote></div><p>Что то такое пробовал, иконка исчезает, но место под неё остаётся зарезервированным.</p><p>---</p><p>Да, я всё это пробовал, потому и стало любопытно, как казалось бы простая вещь, реализована.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-01-05T18:34:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90010#p90010</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск и выделение текста в поле Edit]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90009#p90009" />
			<content type="html"><![CDATA[<p>По идее иконка должна убираться, если посылать <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms632643%28v=vs.85%29.aspx">WM_SETICON</a> с нулевым хендлом, но не срабатывает.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-01-05T18:13:41Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90009#p90009</id>
		</entry>
</feed>
