Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_FileSearch


  • Please log in to reply
11 replies to this topic

#1 w0uter

w0uter

    resreveR nA

  • Active Members
  • PipPipPipPipPipPip
  • 2,262 posts

Posted 30 September 2005 - 03:53 PM

decided to gave it its own post since it was faster then anything i have seen.

Func _FileSearch($s_Mask = '', $i_Recurse = 1)     Local $s_Command = ' /c dir /B "'     If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "'     Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', @WorkingDir, @SW_HIDE, 2+4)     ProcessSetPriority($i_Pid, 5)     While Not @error         $s_Buf &= StdoutRead($i_Pid)     WEnd     $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1)     ProcessClose($i_Pid)     If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1)     Return $s_Buf EndFunc  ;==>_FileSearch



new: added optional sub search

Edited by w0uter, 13 December 2005 - 04:05 PM.

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll







#2 Wb-FreeKill

Wb-FreeKill

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 647 posts

Posted 30 September 2005 - 06:59 PM

Stupid question, how do i use this? ;)

#3 w0uter

w0uter

    resreveR nA

  • Active Members
  • PipPipPipPipPipPip
  • 2,262 posts

Posted 30 September 2005 - 07:02 PM

$t = TimerInit() $var = _FileSearch('C:\*.bat') ConsoleWrite(Timerdiff($t) & @CRLF) For $i = 1 to $var[0] ConsoleWrite($var[$i] & @LF) Next

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

#4 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 30 September 2005 - 09:08 PM

Here is a text file search using similar algorithm.

Func _TextSearch($s_Mask = "",$text = "",$recursive = 0)     Local $s_Buf = ""     Dim $array[1]         If $recursive Then         $i_Pid = Run(@ComSpec & ' /c findstr /I /M /P /S /C:"' & $text & '" "' & $s_Mask & '"',@WorkingDir,@SW_HIDE,2)     Else         $i_Pid = Run(@ComSpec & ' /c findstr /I /M /P /C:"' & $text & '" "' & $s_Mask & '"',@WorkingDir,@SW_HIDE,2)     EndIf         While Not @error         $s_Buf &= StdoutRead($i_Pid)     WEnd         return StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) EndFunc

Edited by livewire, 01 October 2005 - 12:23 AM.


#5 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 01 October 2005 - 12:19 AM

Yep wOuter, these are the fastest that I've seen so far. I figured out why I got bad data comparing the scripts...I had "Indexing Service" turned off.



Note: Make sure "Indexing service" is enabled for best results.



-Livewire

#6 Simucal

Simucal

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 777 posts

Posted 20 June 2006 - 01:35 AM

This is damn fast. Was exactly what I was looking for. Other scripts using _FileFindFirst/Next were prohibitively slow.

Thanks w0uter
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

#7 nitro322

nitro322

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 05 September 2006 - 03:33 AM

Can anyone please tell me why this doesn't work for me?

Plain Text         
$var = _FileSearch('C:\*.bat') dim $results For $i = 1 to $var[0] $results &= $var[$i] & @CRLF Next msgbox(0, 'Test', $results) Func _FileSearch($s_Mask = '', $i_Recurse = 1)     Local $s_Command = ' /c dir /B "'     If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "'     Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', @WorkingDir, @SW_HIDE, 2+4)     ProcessSetPriority($i_Pid, 5)     While Not @error         $s_Buf &= StdoutRead($i_Pid)     WEnd     $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1)     ProcessClose($i_Pid)     If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1)     Return $s_Buf EndFunc ;==>_FileSearch

It's basically the exact code that's pasted above, just using a msgbox() rather than consolewrite().

It should return 3 batch files, but I don't get anything returned. Here's what command shows when I run it manually:

C:\>cmd /c dir /B /S c:\*.bat c:\AUTOEXEC.BAT c:\Program Files\Vim\vimtutor.bat c:\WINDOWS\system32\MsDtc\Trace\msdtcvtr.bat

So what am I doing wrong? I'm running AutoIt 3.2.0.1. Thanks.

#8 nitro322

nitro322

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 05 September 2006 - 03:38 AM

Nevermind. It figures that I figure it out as soon as I post the question. The ProcessSetPriority() line seems to be causing the problem. When I remove that line, it works everytime. If I leave it in, it works about 1 out of every 10 times. Weird.

Anyway, just a heads up if anyone else has a similar problem.

#9 MHz

MHz

    Just simple

  • MVPs
  • 5,727 posts

Posted 05 September 2006 - 04:11 AM

Change the While Not error to Do...Until @error as the previous is also checking ProcessSetPriority() for error which you do not want.
Removing ProcessSetPriority() altogether is a much better idea as I see it doing little anyway.

Edited by MHz, 05 September 2006 - 04:12 AM.


#10 nitro322

nitro322

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 05 September 2006 - 04:39 PM

I ended up just removing it altogether. Like you said, there didn't seem to be much benefit, at least not in my case.

#11 Simucal

Simucal

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 777 posts

Posted 06 September 2006 - 01:39 AM

I had the same problems a long time ago, I removed the Process Priority line as well.
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

#12 Koala

Koala

    Seeker

  • New Members
  • 4 posts

Posted 05 October 2006 - 08:51 AM

I have use this to write a small file search:

Plain Text         
; start directory const $programpath = @SystemDir ; Search recursive? ; @param  bool  True/False Local $SearchRecurse = False ; example - search this files Local $DateiArray[4] $DateiArray[0] = "eula.txt"; exist $DateiArray[1] = "foo.dll" ; not exist $DateiArray[2] = "hid.dll" ; exist $DateiArray[3] = "ias.mdb" ; exist in system32/ias/ Local $DateiGefunden For $i = 0 to UBound($DateiArray) -1   Local $var = _FileSearch($programpath & '\' & $DateiArray[$i], $SearchRecurse)   if $var[1] <> '' Then $DateiGefunden &= $DateiArray[$i] & @LF Next MsgBox(0, "File found!", 'This files found: '& @CRLF&@CRLF & $DateiGefunden ) ; File Search ; ; @param  string  file name or file mask (*.txt) ; @param  bool  True/False ; @return array   [0] - ?, [1] - file name Func _FileSearch($s_Mask = '', $i_Recurse = 1)     Local $s_Command = ' /c dir /B "'     If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "'     Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', @WorkingDir, @SW_HIDE, 2+4) ;~   ProcessSetPriority($i_Pid, 5)     While Not @error       $s_Buf &= StdoutRead($i_Pid)     WEnd     $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) ;~   ProcessClose($i_Pid)     If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1)     Return $s_Buf EndFunc ;==>_FileSearch





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users