Popular Post Nine Posted April 8, 2020 Popular Post Share Posted April 8, 2020 (edited) I don't know if you are like me, but I am always searching for that specific code I wrote over the years, but cannot find it. It was way too exhausting to look at 1k+ scripts. And Windows Explorer is not the best tool to do such exploration. So I made this little script that save me tons of time. Hope you will find it useful too. You can adjust default search folders and type of files you want to search for, but you can also change it at runtime. To use multiple filters separate them with ";" Let me know if you have any suggestion to enhance the tool. Version 2023-12-27 * Code revision : 3.3.16.1 now required Version 2023-05-10 * Sets children flag on first drawn list Version 2021-04-06 * Context menu modified to allow clipping file name and line content Version 2020-11-21 * Allows only 1 running instance of the script * Added right-click support on Tray to exit script Version 2020-06-29 * Added Copy File Name to context menu (helps to copy include files names) Version 2020-04-22 * Added icons to main buttons * Added informative box to describe progress and results of a search * Increased robustness of the GUI * Open Button enabled only under the right conditions * Added Tooltip on filter field to describe how to enter multiple criteria * Forced a minimum Window size Version 2020-04-18 * Added support of Context Menu in Tree View * Added support of Tray * Minimizes on Tray Version 2020-04-12 * Added DPI awareness * Added Enter Key functionality to start a search Version 2020-04-09 * Changed base size of the GUI to make it wider * Made the window resizable * Added Reset button * Shown busy cursor more appropriately * Corrected bug of first line displayed Thanks all for your input. SearchContent.au3 Edited December 27, 2023 by Nine argumentum, Jangal, taurus905 and 11 others 10 4 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
jchd Posted April 8, 2020 Share Posted April 8, 2020 Not meaning your program is bad, just a hint: I use(d) both AgentRansack and FileLocator from https://www.mythicsoft.com/ with high satisfaction. Danp2 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
jcpetu Posted April 8, 2020 Share Posted April 8, 2020 Nine, thumbs up from me. Clear, neat, concise and useful peace of code. Thanks a lot. Regards. Nine 1 Link to comment Share on other sites More sharing options...
Nine Posted April 8, 2020 Author Share Posted April 8, 2020 Glad you like it “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted April 8, 2020 Share Posted April 8, 2020 2 hours ago, Nine said: Let me know if you have any suggestion to enhance the tool. Thanks for writing this nice little tool. As @jchd pointed out, there are already a lot of external textfinders, but for quick searches yours is very useful. Furthermore, it is also a good example script for others . Suggestions : The width of the GUI and controls is fixed. The TreeView control ($idTreeFile) and the Combo control ($idFolder) could be a bit wider. On the other hand, anyone can easily customize that themselves. A button to reset the display for a new search might be a good addition. Nine 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Danp2 Posted April 8, 2020 Share Posted April 8, 2020 +1 for AgentRansack 😃 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted April 8, 2020 Author Share Posted April 8, 2020 @Musashi Will do. Thanks. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
marcgforce Posted April 9, 2020 Share Posted April 9, 2020 Untouch but adding the new search basic method by restarting script and modifying the $ARRAY_OF_FOLDERS = [@scriptdir, @MyDocumentsDir] Nice work... expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <GuiTreeView.au3> #include <File.au3> Opt("MustDeclareVars", 1) Const $ARRAY_OF_FOLDERS = [@scriptdir, @MyDocumentsDir] Const $DEFAULT_FILTER = "*.au3" Local $hGUI = GUICreate("Search Content", 600, 440, 190, 120) GUISetFont(11) Local $idSelect = GUICtrlCreateButton("Select Folder", 25, 20, 135, 30) Local $idFolder = GUICtrlCreateCombo("", 185, 24, 400, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlCreateLabel("Filter :", 25, 58, 50, 25) Local $idFilter = GUICtrlCreateInput($DEFAULT_FILTER, 70, 55, 90, 25) GUICtrlCreateLabel("Text to search :", 185, 58, 100, 25) Local $idText = GUICtrlCreateInput("", 285, 55, 300, 25) Local $idTreeFile = GUICtrlCreateTreeView(25, 90, 560, 300) GUICtrlSetFont(-1, 9) Local $idSearch = GUICtrlCreateButton("Search", 100, 400, 100, 25) Local $idOpen = GUICtrlCreateButton("Open", 400, 400, 100, 25) local $idNewSearch = GUICtrlCreateButton("New Search", 230, 400, 150, 25) GUISetState(@SW_SHOW) Local $sFolder, $idTVselect, $aSelect[1], $idParent GUICtrlSetData($idFolder, _ArrayToString($ARRAY_OF_FOLDERS), $ARRAY_OF_FOLDERS[0]) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idSelect $sFolder = FileSelectFolder("Select root folder", @ScriptDir, 0, @ScriptDir, $hGUI) If @error Then ContinueLoop GUICtrlSetData($idFolder, $sFolder, $sFolder) Case $idSearch If Not GUICtrlRead($idFolder) Or Not GUICtrlRead($idFilter) Then MsgBox($MB_SYSTEMMODAL, "Error", "You must provide folder and filter fields") ContinueLoop EndIf ReDim $aSelect[1] $aSelect[0] = 0 SearchText($idTreeFile, GUICtrlRead($idFolder), GUICtrlRead($idFilter), GUICtrlRead($idText)) Case $idOpen $idTVselect = GUICtrlRead($idTreeFile) If Not $idTVselect Or _GUICtrlTreeView_GetParentHandle($idTreeFile, $idTVselect) Then MsgBox($MB_SYSTEMMODAL, "Error", "Please select file you want to open") ContinueLoop EndIf OpenFile(GUICtrlRead($idTreeFile, $GUI_READ_EXTENDED), GUICtrlRead($idText)) Case $idNewSearch _RestartProgram() EndSwitch $idTVselect = GUICtrlRead($idTreeFile) If $idTVselect Then If _GUICtrlTreeView_GetParentHandle($idTreeFile, $idTVselect) Then ContinueLoop For $i = 1 To $aSelect[0] If $idTVselect = $aSelect[$i] Then ContinueLoop 2 Next _ArrayAdd($aSelect, $idTVselect) $aSelect[0] += 1 DisplayLine($hGUI, $idTreeFile, $idTVselect, ControlTreeView($hGUI, "", $idTreeFile, "GetSelected"), GUICtrlRead($idText)) EndIf WEnd Func SearchText($idTree, $sFolder, $sFilter, $sText) Local Const $CURSOR_WAIT = 15 Local $bFound = False _GUICtrlTreeView_DeleteAll($idTree) Local $aFile = _FileListToArrayRec($sFolder, $sFilter, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then Return MsgBox($MB_SYSTEMMODAL, "Error", "No file selected") GUISetCursor($CURSOR_WAIT, $GUI_CURSOR_OVERRIDE) For $i = 1 To $aFile[0] If Not $sText Or StringInStr(FileRead($aFile[$i]), $sText) Then GUICtrlCreateTreeViewItem($aFile[$i], $idTree) $bFound = True EndIf Next GUISetCursor() If Not $bFound Then MsgBox($MB_SYSTEMMODAL, "Error", "Text not found") EndFunc ;==>SearchText Func DisplayLine($hGUI, $idTree, $idItem, $sItem, $sText) If Not $sText Then Return Local $aLine = FileReadToArray($sItem) For $i = 1 To UBound($aLine) - 1 If StringInStr($aLine[$i], $sText) Then GUICtrlCreateTreeViewItem($aLine[$i], $idItem) Next ControlTreeView($hGUI, "", $idTree, "Expand", $sItem) EndFunc ;==>DisplayLine Func OpenFile($sFile, $sText) Local $sDrive, $sDir, $sFileName, $sExtension _PathSplit($sFile, $sDrive, $sDir, $sFileName, $sExtension) ClipPut($sText) ShellExecute($sFile, "", $sDrive & $sDir, "open") EndFunc ;==>OpenFile #Region --- Restart Program --- Func _RestartProgram() If @Compiled = 1 Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc; ==> _RestartProgram #EndRegion --- Restart Program --- Jangal and Nine 1 1 Link to comment Share on other sites More sharing options...
seadoggie01 Posted April 9, 2020 Share Posted April 9, 2020 (edited) I haven't quite hit 1K scripts 😵, but this is still very helpful! If you feel like being fancy, you can even have an option to open the file to the specific line in SciTE. (I have some code somewhere, excuse me while I use this to find it! ) Edit: Found it Spoiler It's pretty difficult, but I couldn't get Run to work with it. I'm not sure why. Func OpenInSciTe($sAu3File, $sLine = Default) ; Gets SciTE from an Ini in case it's installed in a non-standard directory Local $sSciTE = SciTEDir() ; If there is no line to jump to If IsKeyword($sLine) Then ShellExecute($sSciTE, '"-open:' & $sAu3File & '"') Else ShellExecute($sSciTE, '"-open:' & $sAu3File & '" -goto:' & $sLine) EndIf If @error Then Return SetError(1, 0, False) EndFunc Edit 2: I really like your use of GUISetCursor to display that it's working! I might move it before _FileListToArrayRec though Edited April 9, 2020 by seadoggie01 Nine and Musashi 1 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2020 Author Share Posted April 9, 2020 (edited) 1 hour ago, marcgforce said: Untouch but adding the new search basic method by restarting script There is no need to restart the script for a new search, just enter new folder and new text, and click search, it will erase the previous search...Anyway, I will be adding this button soon, along with other features asked. Edited April 9, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2020 Author Share Posted April 9, 2020 56 minutes ago, seadoggie01 said: If you feel like being fancy, you can even have an option to open the file to the specific line in SciTE I also use it for other languages, and Scite is not always the editor. I wanted to make it as general as possible. As for the cursor I will implement it also. Thanks. seadoggie01 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2020 Author Share Posted April 9, 2020 New version available. I removed the code, hope you don't mind (only kept the download). I felt it made the post encumbered. Let me know if you prefer having the code, I will add it again. seadoggie01 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted April 9, 2020 Share Posted April 9, 2020 I probably found a small bug. If the search term occurs in the first line of the source code, it will not be displayed as a "sub-item". Additional matches (if any) in the lines 2..n will be shown. 1. ; Test by Musashi MsgBox(0,'Info','Click OK') ==> no "sub-item" 2. ; Info : (or even a blank line) ; Test by Musashi MsgBox(0,'Info','Click OK') ==> "sub-item" ok "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
seadoggie01 Posted April 9, 2020 Share Posted April 9, 2020 Does FileReadToArray return a 0 or 1 based array? I think that may be the issue. It's undocumented though All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Danp2 Posted April 9, 2020 Share Posted April 9, 2020 Appears to be 0-based. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2020 Author Share Posted April 9, 2020 You are right, the loop should start at 0 not 1. Good catch. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted April 9, 2020 Share Posted April 9, 2020 (edited) 5 minutes ago, Danp2 said: Appears to be 0-based. Yes ! The problem is easy to solve. It was 'harder' to discover it by accident . Func DisplayLine($hGUI, $idTree, $idItem, $sItem, $sText) If Not $sText Then Return Local $aLine = FileReadToArray($sItem) For $i = 0 To UBound($aLine) - 1 Edited April 9, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Danp2 Posted April 9, 2020 Share Posted April 9, 2020 You can get the line count from @extended as well. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2020 Author Share Posted April 9, 2020 Corrected in first post. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted April 12, 2020 Author Share Posted April 12, 2020 New version available. Thanks @Musashi for the idea of DPI awareness. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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