cramaboule Posted May 8, 2011 Share Posted May 8, 2011 (edited) Hello,As I was fed up of the search engine of windows, I decided to create my own...Can search word inside txt, ini, au3,...Much faster than Windows...If you leave blank the 'word inside file' then it search for files only!Filters like: *.* or *.jpg,...enjoyexpandcollapse popup#include <File.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $sRet Local $j , $aArayFound[1] , $a=0 , $b=0 #Region ### START Koda GUI section ### Form= $Gui = GUICreate("Search Engine", 553, 535, -1, -1) $iFolder = GUICtrlCreateInput("Folder to look in", 160, 10, 121, 21, $ES_READONLY) $bChoose = GUICtrlCreateButton("Choose Folder", 290, 10, 91, 21) $iFilter = GUICtrlCreateInput("Filter: *.*", 160, 50, 121, 21) $iWord = GUICtrlCreateInput("word inside file", 160, 90, 121, 21) $eEdit = GUICtrlCreateEdit("", 0, 120, 551, 411) $bSearch = GUICtrlCreateButton("Search", 290, 50, 91, 61,$BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;http://www.autoitscript.com/forum/topic/126552-solved-guictrlcreateinput-question/ While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $bChoose $sPath=FileSelectFolder ( "Choose Folder", "" , 0 , "" , GUICreate("") ) GUICtrlSetData( $iFolder, $sPath) Case $GUI_EVENT_PRIMARYDOWN $aCInfo = GUIGetCursorInfo($Gui) If $aCInfo[4] = $iFilter And $a = 0 Then GUICtrlSetData($iFilter, "") $a = 1 EndIf If $aCInfo[4] = $iWord And $b = 0 Then GUICtrlSetData($iWord, "") $b = 1 EndIf Case $bSearch If Not (StringInStr(GUICtrlRead($iFolder), ":\")) Then $MsgBox=MsgBox(5 + 16 , "Error", "The input folder is not correct:"&@CRLF&"Retry = Choose an another"&@CRLF&"Cancel = Exit") If $MsgBox <> 4 Then Exit EndIf EndIf If StringInStr(GUICtrlRead($iFilter), "Filter") Then $MsgBox=MsgBox(5 + 16 , "Error", "The input filter is not correct:"&@CRLF&"Retry = Choose an another"&@CRLF&"Cancel = Exit") If $MsgBox <> 4 Then Exit EndIf EndIf If StringInStr(GUICtrlRead($iWord), "word inside file") Then GUICtrlSetData( $iWord, "") EndIf GUICtrlSetData($eEdit, "Please Wait...") _Search(GUICtrlRead($iWord), GUICtrlRead($iFilter), GUICtrlRead($iFolder)) EndSwitch WEnd Func _Search($sSearchString, $sFindFile , $sPath) $aRetArray = _FindPathName($sPath, $sFindFile) If $sSearchString <> "" Then For $i = 1 To $aRetArray[0]-1 $file = FileOpen($aRetArray[$i], 0) If $file = -1 Then Else $text = FileRead($file) If StringInStr( $text , $sSearchString, 1)>0 Then $j += 1 ReDim $aArayFound[$j+1] $aArayFound[$j]=$aRetArray[$i] EndIf EndIf FileClose($file) Next ;~ _ArrayDisplay($aArayFound, "List of file with the String: "&$sSearchString&" found") $sEdit = "" For $i = 1 To UBound($aArayFound)-1 $sEdit &= $aArayFound[$i] & @CRLF Next GUICtrlSetData($eEdit, $sEdit) Else ;~ _ArrayDisplay($aRetArray,"List of folders found") $sEdit = "" For $i = 1 To UBound($aRetArray)-1 $sEdit &= $aRetArray[$i] & @CRLF Next GUICtrlSetData($eEdit, $sEdit) EndIf EndFunc ;~ http://www.autoitscript.com/forum/topic/95160-file-searcher ; Searches all subfolders of $sPath for $sFindFile (* and ? wildcards accepted) ; Returns an array containing full path and name of all matches. ; Number of matches is in zero index of array Func _FindPathName($sPath, $sFindFile) ;ConsoleWrite($sPath & @CRLF) Local $sSubFolderPath, $iIndex, $aFolders $search = FileFindFirstFile($sPath & "\" & $sFindFile) $aFolders = _FileListToArray($sPath, "*", 2) $error=@error While 1 $file = FileFindNextFile($search) If @error Then ExitLoop Else $sRet &= $sPath & "\" & $file & "|" EndIf WEnd FileClose($search) If $error = 0 Then ; no folder For $iIndex = 1 To $aFolders[0] $sSubFolderPath = $sPath & "\" & $aFolders[$iIndex] $aFoldersSubs = _FileListToArray($sSubFolderPath, "*", 2) If IsArray($aFoldersSubs) Then _FindPathName($sSubFolderPath, $sFindFile) Next EndIf Return StringSplit(StringTrimRight($sRet,1), "|") EndFunc ;==>_FindPathNameI took some part of 'Malkey' 's script And an another part of 'Melba23' 's script CramabouleEDIT1: Corrected referanceEDIT2: Changed program Edited May 8, 2011 by cramaboule dakotadevada 1 My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website Link to comment Share on other sites More sharing options...
JScript Posted May 8, 2011 Share Posted May 8, 2011 And about search inside of files (like .txt, .inf, .log, .ini and etc). Thanks for sharing... http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
cramaboule Posted May 8, 2011 Author Share Posted May 8, 2011 And about search inside of files (like .txt, .inf, .log, .ini and etc).Thanks for sharing...That't what it does.... Maybe I explain myself wrong ...It does look inside files even *.au3 !!!!! My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website 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