w0uter Posted September 30, 2005 Share Posted September 30, 2005 (edited) 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 December 13, 2005 by w0uter pixelsearch 1 My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted September 30, 2005 Share Posted September 30, 2005 Stupid question, how do i use this? Link to comment Share on other sites More sharing options...
w0uter Posted September 30, 2005 Author Share Posted September 30, 2005 $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 Link to comment Share on other sites More sharing options...
livewire Posted September 30, 2005 Share Posted September 30, 2005 (edited) 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 October 1, 2005 by livewire Link to comment Share on other sites More sharing options...
livewire Posted October 1, 2005 Share Posted October 1, 2005 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 Link to comment Share on other sites More sharing options...
Simucal Posted June 20, 2006 Share Posted June 20, 2006 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) Link to comment Share on other sites More sharing options...
nitro322 Posted September 5, 2006 Share Posted September 5, 2006 Can anyone please tell me why this doesn't work for me? $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. http://www.legroom.net/ Link to comment Share on other sites More sharing options...
nitro322 Posted September 5, 2006 Share Posted September 5, 2006 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. http://www.legroom.net/ Link to comment Share on other sites More sharing options...
MHz Posted September 5, 2006 Share Posted September 5, 2006 (edited) 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 September 5, 2006 by MHz Link to comment Share on other sites More sharing options...
nitro322 Posted September 5, 2006 Share Posted September 5, 2006 I ended up just removing it altogether. Like you said, there didn't seem to be much benefit, at least not in my case. http://www.legroom.net/ Link to comment Share on other sites More sharing options...
Simucal Posted September 6, 2006 Share Posted September 6, 2006 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) Link to comment Share on other sites More sharing options...
Koala Posted October 5, 2006 Share Posted October 5, 2006 I have use this to write a small file search: expandcollapse popup; 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now