<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Поиск по файлам строк, содержащих слово]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5895&amp;type=atom" />
	<updated>2018-08-22T16:29:35Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5895</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128187#p128187" />
			<content type="html"><![CDATA[<p>Создавайте finddata.txt в UTF-8.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-08-22T16:29:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128187#p128187</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128185#p128185" />
			<content type="html"><![CDATA[<p>А если входной файл в UTF-8? Вот так не ищется:<br /></p><div class="codebox"><pre><code>findstr /i /g:finddata.txt E:\BASE\M.txt &gt; results.out</code></pre></div><p>В файле &quot;finddata.txt&quot; кириллич. слово.</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2018-08-22T16:17:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128185#p128185</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128184#p128184" />
			<content type="html"><![CDATA[<p>Если строка с кириллицей, создаём временный текстовый файл с поисковым словом, затем применяем ключ /G.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-08-22T15:53:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128184#p128184</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128183#p128183" />
			<content type="html"><![CDATA[<p>Нет ли решения по <a href="http://forum.script-coding.com/viewtopic.php?pid=66876#p66876">проблеме с кодировкой</a> для findstr, т.к. 7-гиг. файл перекодировать вообще не забавно?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2018-08-22T15:46:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128183#p128183</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128176#p128176" />
			<content type="html"><![CDATA[<p>Скрипт разогнать никак нельзя, можно разогнать только скриптописателей. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /> Для быстрого поиска в больших файлах лучше пользоваться утилитой командной строки findstr.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-08-22T14:05:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128176#p128176</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128173#p128173" />
			<content type="html"><![CDATA[<p>Можно ли разогнать этот скрипт для поиска внутри 7-гиг. файла?<br /></p><div class="codebox"><pre><code>
#SingleInstance force
#NoEnv
#MaxMem 400
SetBatchLines -1

Res := &quot;E:\Путь_К_Файлу.txt&quot;
targetFile = %A_ScriptDir%\FLines.txt
searchedWord = ИскомоеСлово

FileDelete, %targetFile%
Loop %Res%
{
   Loop Read, %A_LoopFileFullPath%, %targetFile%
   {
      IfInString A_LoopReadLine, %searchedWord%    ;с ней быстрее
      {
         Loop Parse, A_LoopReadLine, `.
         {
            IfInString A_LoopField, %searchedWord%
            {
               FileAppend, %A_LoopReadLine%`r`n, %targetFile%, UTF-8
            }
         }
      }
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2018-08-22T13:23:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128173#p128173</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111838#p111838" />
			<content type="html"><![CDATA[<p><em></em></p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2017-02-04T06:51:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111838#p111838</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Поиск по файлам строк, содержащих слово]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49067#p49067" />
			<content type="html"><![CDATA[<p>Win+F — показать окно скрипта<strong><span style="color: red"><span class="bbu">.</span></span></strong></p><p>Вопрос: как научить его вести поиск также по документам, кодированным UTF-8 ?</p><div class="codebox"><pre><code>#SingleInstance force

#SC021::		;Win+F
Word_Searcher:
  hWnd := WinExist(&quot;A&quot;)
  WinGetClass wClass, ahk_id %hWnd%
    Res := GetWindowsExplorerPath(hWnd)
      IfWinActive, ahk_class Progman
      Res := A_DESKTOP

foldersel=%Res%
targetFile = %A_ScriptDir%\FLines.html

Gui, 34:+LastFound +Caption -minimizebox
Gui, 34:Add, Edit, r1 w300  yp+15          vsearchedWord, %searchedWord%
Gui, 34:Add, Button,  xp+300 default w80 , Искать
Gui, 34:Add, Edit, r1 w300  xp-300 yp+22   vfoldersel, %foldersel%
Gui, 34:Add, Button,  xp+300         w80 , Обзор...
Gui, 34:Add, Checkbox, Checked0  xp-300 yp+40  vrec, смотреть в подпапках
Gui, 34:Add, Checkbox, gextents  Checked0  xp+190 yp-0  vext, с расширением
Gui, 34:Add, ComboBox , disabled Uppercase xp+125 w60 vextchoice, AHK|BAT|CMD|CSS|HTM|HTML|PHP|TXT|LOG|INF|INI|HTA|JS|VBS|WSF|REG
extents:
ControlGet, variab, Checked,, Button8, 
Control, Enable,, ComboBox1,
Gui, 34:Show, w400 h120, LinesCatcher
return
34ButtonОбзор...:
FileSelectFolder, obzor, ,
IF (obzor&lt;&gt;&quot;&quot;)
GuiControl,34:, foldersel, %obzor%
return
34ButtonИскать:
CoordMode, ToolTip, Screen
ToolTip, ...,0,0
Gui, Submit, hide
SetWorkingDir %foldersel%
IF ext=1
extention = %extchoice%
ELSE
extention=*

FileDelete, %A_ScriptDir%\FLines.html
{
  FileAppend,
  (LTrim
  &lt;html&gt;`n&lt;head&gt;`n&lt;title&gt;[FLines]&lt;/title&gt;&lt;base target=&quot;parent&quot; /&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1251&quot;/&gt;
  &lt;STYLE type=&quot;text/css&quot;&gt;`n&lt;!--
  body {BACKGROUND:url(&#039;/n.gif&#039;) no-repeat; BACKGROUND-ATTACHMENT:fixed; BORDER:none;
    BACKGROUND-COLOR:#A8C1AE; FONT-FAMILY:serif; MARGIN:5`% 22`% 20`% 22`%; PADDING:0;}
  #header {POSITION:fixed; Z-INDEX:1; TOP:0; RIGHT:0; //POSITION:absolute; TOP:expression(
    document.getElementsByTagName( &#039;body&#039; )[0].scrollTop + &quot;px&quot;);}`n#content {}
  a {COLOR:#990000; FONT-FAMILY:Tahoma, Helvetica, Geneva;
    FONT-SIZE:7.5pt; FONT-WEIGHT:bold; TEXT-DECORATION:none;}
  a:hover {COLOR:blue;}`na:visited {COLOR:#990099;}
  b {BACKGROUND-COLOR:#FF9999; COLOR:#000000; FONT-SIZE:17px;
    BORDER-TOP:2px solid #bb4000; BORDER-BOTTOM:2px solid #bb4000;}
  td {BACKGROUND-COLOR:#effeee; BORDER:1px solid black;
    PADDING:7px 13px 7px 13px; BORDER-BOTTOM:0px; FONT-SIZE:16px;}
  #searchbox {WIDTH:220px; HEIGHT:22px; LINE-HEIGHT:18px; border:1px #728776 solid;
    background-color:#EFFEEE;}`n.hidden {DISPLAY:none;}
  --&gt;`n&lt;/STYLE&gt;

  &lt;script type=&quot;text/javascript&quot;&gt;
  var keyTimerId=0;
  function prevEle(e){do{e=e.previousSibling} while(e &amp;&amp; e.nodeType != 1); return e};
  function nextEle(e){do{e=e.nextSibling} while(e &amp;&amp; e.nodeType != 1); return e};
  function isVisible(e){var rows=e.rows; for(var i=0, r; r=rows[i]; i++){if(!r.className || r.className == &#039;visible&#039;)return true}};
  function find(){var div, tb, h; var val=document.getElementById(&#039;searchbox&#039;).value.toLowerCase();
  var lnks=document.getElementsByTagName(&#039;span&#039;);for(var i=0, li; li=lnks[i]; i++){
  div=li.parentNode.parentNode; div.className=((li.textContent || li.innerText).toLowerCase().indexOf(val) != -1) ? &#039;visible&#039; : &#039;hidden&#039;;
  if(!nextEle(div)){tb=div.parentNode.parentNode; h=prevEle(tb);
  if(isVisible(tb)){tb.className=&#039;visible&#039;; h.className=&#039;visible&#039;}else{tb.className=&#039;hidden&#039;; h.className=&#039;hidden&#039;};}}};
  function addInfo(text) {var fieldRef;if(fieldRef=document.getElementById(&#039;searchbox&#039;))
  {fieldRef.value = text;find()}return false;}
  &lt;/script&gt;`n&lt;/head&gt;`n&lt;body onDblClick=&quot;document.getElementById(&#039;searchbox&#039;).focus()&quot;&gt;`n`n&lt;div id=&quot;header&quot;&gt;
  &lt;INPUT type=&quot;text&quot; value=&quot;Быстрый поиск&quot; id=&quot;searchbox&quot;
  onfocus=&quot;if(this.value==this.defaultValue)this.value=&#039;&#039;;&quot;
  onblur=&quot;if(!this.value)this.value=this.defaultValue;&quot;
  onkeyup=&quot;clearTimeout(keyTimerId);keyTimerId=setTimeout(&#039;find()&#039;,500);&quot;
  onDblClick=&quot;return addInfo(&#039;&#039;);&quot;&gt;`n&lt;/div&gt;`n&lt;div id=&quot;content&quot;&gt;
  &lt;table width=100`% cellspacing=0 cellpadding=0 border=0 style=&quot;BORDER-BOTTOM:1px solid #000000;&quot;&gt;`n`n`n
), %A_ScriptDir%\FLines.html
}

Loop *.%extention%, 0, %rec%     ;, 0,1  -  искать в подп
{
  If (A_LoopFileFullPath != targetFile)
  {
    Loop Read, %A_LoopFileFullPath%, %targetFile%
    {
      IfInString A_LoopReadLine, %searchedWord%    ;с ней быстрее
      {
        Loop Parse,A_LoopReadLine, `.
        {
          IfInString A_LoopField, %searchedWord%
          {
            Str = %A_LoopField%
            StringReplace, Str, Str, %A_Space%%A_Space%%A_Space%, &amp;nbsp`;&amp;nbsp`;&amp;nbsp`;, All
            StringReplace, Str, Str, %A_Space%%A_Space%, &amp;nbsp`;&amp;nbsp`;, All
           ;StringReplace, Str, Str, %A_Tab%, &amp;nbsp`;&amp;nbsp`;&amp;nbsp`;, All
            StringReplace, Str, Str, &lt;, &amp;lt`;, All
            StringReplace, Str, Str, &gt;, &amp;gt`;, All
            StringReplace, Str, Str, %searchedWord%, &lt;b&gt;%searchedWord%&lt;/b&gt;, All
            FileAppend, &lt;tr&gt;&lt;td&gt;&lt;span&gt;`r`n%Str%.`r`n&lt;/span&gt;&lt;a href=&quot;file:\\%foldersel%\%A_LoopFileFullPath%&quot;&gt;%A_LoopFileName%&lt;/a&gt;`r`n&lt;/td&gt;&lt;/tr&gt;`r`n`r`n
          }
        }
      }
    }
  }
}

  Run, %A_ScriptDir%\FLines.html
  Sleep, 600
  tooltip
  Gui, 34:destroy
  return

34GuiClose:
34GuiEscape:
  Gui, 34:destroy
  return


; Определение текущего пути в окне Проводника
GetWindowsExplorerPath(_hWnd) 
{ 
   local pid, hMem, pv, pidl, pidl_, explorerPath 
   If (A_OSType = &quot;WIN32_NT&quot;) 
   { 
      pid := DllCall(&quot;GetCurrentProcessId&quot;) 
      SendMessage 0x400 + 12, pid, 0,, ahk_id %_hWnd% 
      hMem := ErrorLevel 
      if (hMem != 0) 
      { 
         pv := DllCall(&quot;Shell32\SHLockShared&quot;, &quot;UInt&quot;, hMem, &quot;UInt&quot;, pid) 
         if (pv != 0) 
         { 
            pidl := DllCall(&quot;Shell32\ILClone&quot;, &quot;UInt&quot;, pv) 
            DllCall(&quot;Shell32\SHUnlockShared&quot;, &quot;UInt&quot;, pv) 
         } 
         DllCall(&quot;Shell32\SHFreeShared&quot;, &quot;UInt&quot;, hMem, &quot;UInt&quot;, pid) 
      } 
   } 
   Else ; Win9x 
   { 
      SendMessage 0x400 + 12, 0, 0, , ahk_id %_hWnd% 
      pidl_ := ErrorLevel 
      if (pidl_ != 0) 
      { 
         pidl := DllCall(&quot;Shell32\ILClone&quot;, &quot;UInt&quot;, pidl_) 
         DllCall(&quot;Shell32\ILGlobalFree&quot;, &quot;UInt&quot;, pidl_) 
      } 
   } 
   VarSetCapacity(explorerPath, 512, 0) 
   DllCall(&quot;Shell32\SHGetPathFromIDList&quot; (A_IsUnicode ?&quot;W&quot;:&quot;A&quot;), &quot;UInt&quot;, pidl, &quot;Str&quot;, explorerPath) 
   Return explorerPath 
}
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2011-06-10T14:14:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49067#p49067</id>
		</entry>
</feed>
