Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ____________________________________________
- ; \____ NajeebSK - EverythingFindStrGui _____/
- ; Coded by Najeeb Shah Khan . Last Edit:- 02/25/2023
- ; Based on "Everything FindStr 1.41" by NSK
- ; Frontend for "Everything" search engine and "FindStr" (finds strings of text in files) apps.
- ; Everything/Es: http://www.voidtools.com/
- ; Download page: http://www.voidtools.com/download.php
- ; Direct download:
- ; Everything: http://www.voidtools.com/Everything-1.2.1.371.exe
- ; Es: http://www.voidtools.com/es.exe
- ; FindStr: C:\Windows\system32
- #SingleInstance Force
- SetBatchLines -1
- SetWorkingDir %A_ScriptDir%
- FileCreateDir,%A_ScriptDir%\Everything
- FileInstall , Everything.ahk, %A_ScriptDir%\Everything.ahk, 1
- FileInstall , Everything\Everything.exe, %A_ScriptDir%\Everything\Everything.exe, 1
- FileInstall , Everything\cli.c, %A_ScriptDir%\Everything\cli.c, 1
- FileInstall , Everything\es.exe, %A_ScriptDir%\Everything\es.exe, 1
- FileInstall , Everything\Everything.lng, %A_ScriptDir%\Everything\Everything.lng, 1
- FileInstall , Everything\findstr.exe, %A_ScriptDir%\Everything\findstr.exe, 1
- FileSetAttrib +HS, %A_ScriptDir%\Everything, 2
- FileSetAttrib +HS, %A_ScriptDir%\Everything.ahk, 2
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- If !A_IsAdmin
- {
- DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
- , str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
- ExitApp
- }
- DriveGet allDrives, list, fixed ; Get drive list
- Loop Parse, allDrives ; Extract all NTFS drives
- {
- l := A_LoopField
- DriveGet thisDrive, FS, %l%:
- If thisDrive = ntfs
- {
- If !firstDrive ; First drive found (usually C:)
- firstDrive := l
- ntfsDrives = %ntfsDrives% %l%
- }
- }
- app_name = NajeebSK - EverythingFindStrGui
- driveShow = Available NTFS drives: %ntfsDrives%
- GUI_name = %app_name% - %driveShow%
- helpFile = Operators.txt
- result_filename = output_everything.txt
- result_filename2 = output_findstr.txt
- iniPath = %app_name%.ini
- progNameSB = %app_name% - Select a file then click status bar to copy full path.
- sbDisplay = Select a file then click status bar to copy full path.
- fileSearchStrings = *.mp3|*.wma¦*.jpg|*.jpeg|*.gif|*.png¦*.ahk
- Gosub cfgLoad
- If savedFileSearchQuery = ERROR
- savedFileSearchQuery=
- If savedStringSearchQuery = ERROR
- savedStringSearchQuery=
- guiNewChoice = %guiChoice%
- esSortPath = %esSortByPath%
- Gosub exeCheck
- If !appNotFound
- Run %everything_app%,, hide, everythingPID
- Gosub doGui
- ;OnMessage(0x200, "WM_MOUSEMOVE")
- Return
- exeCheck:
- IfNotExist %A_ScriptDir%\Everything\Everything.exe
- appNotFound = Everything: %A_ScriptDir%\Everything\Everything.exe`n
- IfNotExist %A_ScriptDir%\Everything\es.exe
- appNotFound = %appNotfound%Es: %A_ScriptDir%\Everything\es.exe`n
- IfNotExist %A_ScriptDir%\Everything\findstr.exe
- appNotFound = %appNotFound%FindStr: %A_ScriptDir%\Everything\findstr.exe
- If appNotFound
- MsgBox The following`n`n%appNotFound%`n`nare needed for this program to work and they cannot be found in their default installation location. Please check that you have them installed then set the paths in this programs Options.
- Return
- doGui:
- If guiNewChoice = 0
- Gosub Gui1
- Else
- Gosub Gui2
- winID := WinExist("A")
- GuiControl focus, command_search
- Gosub loadOptions
- Sleep 500
- WinActivate ahk_ID %winID%
- Return
- ; ****************** WIDE GUI ******************
- Gui1:
- Gui 1:Margin, 5, 5
- Gui 1:+MinSize +LastFound
- Gui 1:+Delimiter¦ ; Pipe is used in searches, use alernate field separator.
- Gui 1:Add, GroupBox, x5 y10 w390 h80 section, Find File
- Gui 1:Add, CheckBox, xs+10 ys+25 vesWW gesOptions, Whole Word
- Gui 1:Add, CheckBox, x+5 vesCase gesOptions, Case
- Gui 1:Add, CheckBox, x+5 vesPath gesOptions, Path
- Gui 1:Add, CheckBox, x+20 vesSortPath gesOptions checked%esSortPath%, Path sort
- Gui 1:Add, CheckBox, x+20 vesRegEx gesOptions, Enable RegEx
- Gui 1:Add, ComboBox, xs+10 yp+25 w247 vcommand_search gsearch , %savedFileSearchQuery%%fileSearchStrings%
- Gui 1:Add, Button, x+1 yp-1 w12 vsaveFileSearchString gsaveFileSearchQuery disabled, +
- Gui 1:Add, Button, x+3 vaddPathButton gaddPathToSearch disabled, +path
- Gui 1:Add, Button, x+10 vshowFileSize gshowFileSize disabled, Show size
- Gui 1:Add, GroupBox, x398 y10 w320 h80 section, Find String
- Gui 1:Add, CheckBox, xs+10 ys+25 vfindLiteral gfindOptions, Literal
- Gui 1:Add, CheckBox, x+5 vfindCase gfindOptions, Case
- Gui 1:Add, CheckBox, x+20 vfindRegEx gfindOptions, Enable RegEx
- Gui 1:Add, Button, x+39 yp-5 vpreviewButton gpreviewResults disabled, Preview
- Gui 1:Add, ComboBox, xs+10 yp+30 w287 vsearch_inside gsearch disabled, %parameter%
- Gui 1:Add, Button, x+1 yp-1 w12 vsaveStringSearchString gsaveStringSearchQuery disabled, +
- Gui 1:Add, GroupBox, x+15 y10 w66 h80 section
- Gui 1:Add, Button, xs+8 ys+13 w50 h20 gswapGui , Gui
- Gui 1:Add, Button, xs+8 yp+20 w50 h20 gapp_options, Options
- Gui 1:Add, Button, xs+8 yp+20 w50 h20 gprogHelp disabled, Help
- GUI 1:Add, ListView, x5 r20 w785 vhitlist glistviewEvent AltSubmit -multi count%max_results% , result¦name¦ext¦size¦path
- LV_ModifyCol(1, 0) ; Hide column 1 (contains files FULL path).
- LV_ModifyCol(2, 300) ; Set "name" column size.
- LV_ModifyCol(3, 45) ; Set "ext" column size.
- LV_ModifyCol(4, 60) ; Set "size" column size.
- LV_ModifyCol(5, 464) ; Set "path" column size.
- Gui 1:Add, StatusBar, gsbCopyFullPath, %progNameSB% ; Clicking SB copies files full path to clipboard.
- GUI 1:Show,, %GUI_name%
- Return
- ; ****************** TABBED GUI ******************
- Gui2:
- Gui 1:Margin, 5, 5
- GUI 1:+MinSize +LastFound
- Gui 1:+Delimiter¦ ; Pipe is used in searches, use alternate field separator.
- Gui 1:Add, Button, x266 w50 h20 gapp_options, Options
- Gui 1:Add, Button, x+0 w50 h20 gprogHelp disabled, Help
- Gui 1:Add, Button, x+0 w50 h20 gswapGui, Gui
- Gui 1:Add, Tab2, x5 y10 w410 h140 vtabVar gwhichTab -wrap -Background, File Search¦String Search
- Gui 1:Tab, File Search
- Gui 1:Add, Text, x10 y38 h20 disabled, Operators:
- Gui 1:Add, Button, x+1 yp-3 w15 h20 disabled, ?
- Gui 1:Add, Button, x+0 w15 h20 disabled, *
- Gui 1:Add, Button, x+0 h20 w20 disabled, ""
- Gui 1:Add, Button, x+0 h20 w15 disabled, |
- Gui 1:Add, Button, x+0 h20 w15 disabled, !
- Gui 1:Add, Button, x+0 h20 w15 disabled, \
- Gui 1:Add, Text, x+9 y38 h20 disabled, RegEx:
- Gui 1:Add, Button, x+1 yp-3 w15 h20 disabled, |
- Gui 1:Add, Button, x+0 h20 w20 disabled, ( )
- Gui 1:Add, Button, x+0 h20 w15 disabled, ?
- Gui 1:Add, Button, x+0 h20 w15 disabled, *
- Gui 1:Add, Button, x+0 h20 w15 disabled, +
- Gui 1:Add, Button, x+0 h20 w15 disabled, .
- Gui 1:Add, Button, x+0 h20 w20 disabled, [ ]
- Gui 1:Add, Button, x+0 h20 w25 disabled, [^ ]
- Gui 1:Add, Button, x+0 h20 w15 disabled, ^
- Gui 1:Add, Button, x+0 h20 w15 disabled, $
- Gui 1:Add, Button, x+0 h20 w35 disabled, {m,n}
- Gui 1:Add, GroupBox, x10 yp+17 w395 h80 section
- Gui 1:Add, CheckBox, xs+10 ys+25 vesWW gesOptions, Whole Word
- Gui 1:Add, CheckBox, x+5 vesCase gesOptions, Case
- Gui 1:Add, CheckBox, x+5 vesPath gesOptions, Path
- Gui 1:Add, CheckBox, x+25 vesSortPath gesOptions checked%esSortPath%, Path sort
- Gui 1:Add, CheckBox, x+20 vesRegEx gesOptions, Enable RegEx
- Gui 1:Add, ComboBox, xs+10 yp+25 w259 vcommand_search gsearch , %savedFileSearchQuery%%fileSearchStrings%
- Gui 1:Add, Button, x+1 yp-1 w12 vsaveFileSearchString gsaveFileSearchQuery disabled, +
- Gui 1:Add, Button, x+3 vaddPathButton gaddPathToSearch disabled, +path
- Gui 1:Add, Button, x+5 vshowFileSize gshowFileSize disabled, Show size
- Gui 1:Tab, String Search
- Gui 1:Add, Text, x10 y38 h20 disabled, RegEx:
- Gui 1:Add, Button, x+15 yp-3 w20 h20 disabled, .
- Gui 1:Add, Button, x+0 h20 w20 disabled, *
- Gui 1:Add, Button, x+0 h20 w20 disabled, ^
- Gui 1:Add, Button, x+0 h20 w20 disabled, $
- Gui 1:Add, Button, x+0 h20 w50 disabled, [class]
- Gui 1:Add, Button, x+0 h20 w55 disabled, [^class]
- Gui 1:Add, Button, x+0 h20 w40 disabled, [x-y]
- Gui 1:Add, Button, x+0 h20 w30 disabled, \x
- Gui 1:Add, Button, x+0 h20 w45 disabled, \<xyz
- Gui 1:Add, Button, x+0 h20 w45 disabled, xyz\>
- Gui 1:Add, GroupBox, x10 yp+17 w395 h80 section
- Gui 1:Add, CheckBox, xs+10 ys+25 vfindLiteral gfindOptions, Literal
- Gui 1:Add, CheckBox, x+5 vfindCase gfindOptions, Case
- Gui 1:Add, CheckBox, x+30 vfindRegEx gfindOptions, Enable RegEx
- Gui 1:Add, Button, x+104 yp-5 vpreviewButton gpreviewResults disabled, Preview
- Gui 1:Add, ComboBox, xs+10 yp+30 w362 section vsearch_inside gsearch disabled, %parameter%
- Gui 1:Add, Button, x+1 yp-1 w12 vsaveStringSearchString gsaveStringSearchQuery disabled, +
- Gui 1:Tab
- GUI 1:Add, ListView, x5 w410 r20 vhitlist glistviewEvent AltSubmit -multi count%max_results% , result¦name¦ext¦size¦path
- LV_ModifyCol(1, 0) ; Hide column 1 (contains files FULL path).
- LV_ModifyCol(2, 200) ; Set "name" column size.
- LV_ModifyCol(3, 45) ; Set "ext" column size.
- LV_ModifyCol(4, 60) ; Set "size" column size.
- LV_ModifyCol(5, 464) ; Set "path" column size.
- Gui 1:Add, StatusBar, gsbCopyFullPath, %progNameSB% ; Clicking SB copies files full path to clipboard.
- GUI 1:Show,, %GUI_name%
- Return
- saveFileSearchQuery:
- Gui Submit, Nohide
- IfNotInString savedFileSearchQuery, %command_search%
- {
- savedFileSearchQuery = %savedFileSearchQuery%¦%command_search%
- GuiControl,, command_search, ¦%savedFileSearchQuery%%fileSearchStrings%
- GuiControl focus, command_search
- SendInput {Raw} %command_search%
- Gosub cfgSave
- }
- Return
- saveStringSearchQuery:
- Gui Submit, Nohide
- IfNotInString savedStringSearchQuery, %search_inside%
- {
- savedStringSearchQuery = %savedStringSearchQuery%¦%search_inside%
- GuiControl,, search_inside, ¦%savedStringSearchQuery%
- GuiControl focus, search_inside
- SendInput {Raw} %search_inside%
- Gosub cfgSave
- }
- Return
- whichTab: ; Select the correct control when selecting
- Gui Submit, Nohide ; different tabs.
- If (tabVar = "File Search")
- GuiControl focus, command_search
- Else
- GuiControl focus, search_inside
- SendInput {End}
- Return
- progHelp:
- Run %helpFile%
- Return
- saveSearchString:
- Return
- showFileSize: ; Showing file size is disabled by default due to
- showSize = 1 ; the excesive time taken to retrieve info from
- Gosub esOptions ; large numbers of files while typing the query.
- showSize= ; Clicking the "show size" button once the search
- Return ; is done runs this routine and fills the size column.
- swapGui: ; Changes from one gui layout to the other.
- If (guiNewChoice = 0)
- guiNewChoice = 1
- Else
- guiNewChoice = 0
- If esWW ; Save all wanted control data ready for new gui.
- esWW = 1
- If esCase
- esCase = 1
- If esPath
- esPath = 1
- If esRegex
- esRegex = 1
- If findLiteral
- findLiteral = 1
- If findCase
- findCase = 1
- If findRegEx
- findRegEx = 1
- If esSortPath
- esSortPath = 1
- If (command_search) {
- IfInString command_search, "|"
- StringReplace command_search, command_search, "|", |, A
- command_search1 = %command_search%
- }
- If search_inside
- search_inside1 = %search_inside%
- Gui 1:Destroy ; Bye-bye old gui.
- Gosub doGui ; Hello new gui.
- If esWW ; Update new gui's controls with saved data.
- GuiControl,, esWW, 1
- If esCase
- GuiControl,, esCase, 1
- If esPath
- GuiControl,, esPath, 1
- If esRegex
- GuiControl,, esRegex, 1
- If findLiteral
- GuiControl,, findLiteral, 1
- If findCase
- GuiControl,, findCase, 1
- If findRegEx
- GuiControl,, findRegEx, 1
- swap = 1
- Gosub esOptions ; Get Es.exe command line options.
- Gosub findOptions ; Get FindStr.exe command line options.
- swap=
- If (command_search1) { ; If there was text in the previous gui's find file
- GuiControl focus, command_search ; search box, place it in the new gui's search box
- SendInput {Raw} %command_search1% ; and do search using the above command line options.
- }
- If search_inside1 ; Same as above but search file's for strings of text.
- GuiControl Text, search_inside, %search_inside1%
- command_search1=
- search_inside1=
- Return
- loadOptions: ; Sets variables for initial search on app start.
- findSearchOptions := "/S /M "
- If (esSortPath)
- esSortPath = -s
- Else
- esSortPath=
- esSearchOptions = %esSortPath%
- Return
- esOptions: ; Sets command line options for es.exe.
- Gui Submit, NoHide
- If (esWW) ; Whole word search.
- esWW = -w
- Else
- esWW=
- If (esCase) ; Case sensitive search.
- esCase = -i
- Else
- esCase=
- If (esPath) ; Search the path.
- esPath = -p
- Else
- esPath=
- If (esRegex) { ; Enable regex search strings.
- esRegex = -r
- GuiControl Disable, esWW
- }
- Else {
- esRegEx=
- GuiControl Enable, esWW
- }
- If (esSortPath) ; Sort the results by path (rather than by name).
- esSortPath = -s
- Else
- esSortPath=
- esSearchOptions = %esSortPath% %esWW% %esCase% %esPath% %esRegEx% ; Completed options string ready to pass on to es.exe.
- If swap ; Gui is being swapped so don't perform search (yet!).
- Return
- Gosub execute_search
- Return
- findOptions: ; Sets command line options for EveryStr.exe.
- Gui Submit, NoHide
- If (findLiteral) ; Search string is literal, eg. "good dog" rather than
- findLiteral := "/C:" ; "good" AND "dog".
- Else
- findLiteral=
- If (findCase) || (findLiteral) ; Default condition is "case sensitive" for the search
- findCase= ; query. Adding /I make the query NOT case sensitive.
- Else
- findCase := "/I "
- If (findRegEx) { ; RegEx.
- findRegex := "/R "
- GuiControl Disable, findLiteral ; These aren't needed if regex is enabled ... I think!
- GuiControl Disable, findCase
- }
- Else {
- findRegEx=
- GuiControl Enable, findLiteral
- GuiControl Enable, findCase
- }
- findSearchOptions := "/S /M " . findCase . findRegEx . findLiteral ; The completed options string.
- If swap
- Return
- Gosub execute_search
- Return
- previewResults:
- Gui Submit, Nohide
- If (search_inside) {
- IfExist %result_filename%
- {
- StringReplace pOpts, findSearchOptions, /M, /N
- FileDelete preview.txt
- ;msgbox "%pOpts%"
- Runwait %comspec% /c ""%findstr_app%" /F:"%result_filename%" %pOpts%"%search_inside%" > "preview.txt"", %A_ScriptDir%, hide
- FileRead result, preview.txt
- Run preview.txt
- }
- result=
- }
- Return
- search:
- SetTimer execute_search, -%update_speed% ;Wait xxx milliseconds after typing stops.
- Return
- execute_search:
- Gui Submit, NoHide ; Retrieve the variables from the GUI
- If (!command_search) { ; Search box is empty so clear the listview
- LV_Delete() ; and, a few controls and vars.
- SB_SetText(progNameSB)
- GuiControl disable, addPathButton
- Guicontrol disable, search_inside
- GuiControl disable, showFileSize
- GuiControl disable, saveFileSearchString
- lvFullPath = Result
- hitCnt=
- Return
- }
- IfInString command_search, |
- StringReplace command_search, command_search, |, "|", all
- IfExist %result_filename% ; Check if the temporary output file exists,
- FileDelete %result_filename% ; if so, delete it.
- Runwait %comspec% /c ""%find_app%" %command_search% %esSearchOptions% -n %max_results% > "%result_filename%"", %A_ScriptDir%, hide
- IfExist %result_filename2% ; Check if the temporary (filtered) output file exists,
- FileDelete %result_filename2% ; if so, delete it.
- If (search_inside) { ; Search retrieved file list for specified text.
- Runwait %comspec% /c ""%findstr_app%" /F:"%result_filename%" %findSearchOptions%"%search_inside%" > "%result_filename2%"", %A_ScriptDir%, hide
- FileDelete %result_filename%
- FileMove %result_filename2%, %result_filename%
- }
- IfExist %result_filename% ; Read the (filtered) outputfile to a variable
- {
- LV_Delete() ; Empty the list ready it for updated/new results
- FileRead , results, %result_filename%
- StringReplace , results , results , `r`n, `n, A ; Needed for the listview.
- GuiControl, -Redraw, Hitlist
- hitCnt = -1
- Loop parse, results, `n
- {
- hitCnt++ ; Start counting the hits.
- SplitPath A_LoopField , OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
- If (showSize) { ; Get files size. This is done manually by the user.
- FileGetSize, fileSize, %A_LoopField%, B
- If fileSize = 0
- fileSize=
- FileGetAttrib isFolder, %A_LoopField%
- IfInString isFolder, D
- {
- OutExtension = !Folder
- fileSize=
- }
- }
- If (outfilename)
- LV_Add("", A_LoopField, OutFileName, OutExtension, fileSize, OutDir)
- }
- GuiControl +Redraw, Hitlist
- If hitCnt = -1
- hitCnt = 0
- SB_SetText(hitCnt " hits. - "sbDisplay)
- If (search_inside) && (hitCnt > 0) { ; Enable/disable some controls dependent on hits.
- GuiControl enable, saveStringSearchString
- Guicontrol enable, previewButton
- GuiControl disable, command_search ; Disable file search input box when text search box
- } ; has content.
- Else {
- GuiControl disable, saveStringSearchString
- GuiControl disable, previewButton
- GuiControl enable, command_search
- }
- }
- Guicontrol enable, search_inside
- GuiControl enable, showFileSize
- GuiControl enable, saveFileSearchString
- GuiControl disable, addPathButton
- LV_ModifyCol(4, "Integer") ; Size column
- results= ; Empty the variables to free up memory
- hitCnt=
- Return
- listviewEvent:
- If (A_GuiEvent = "DoubleClick") { ; Listview was double clicked.
- Gosub listviewInfo
- If (lvFullPath <> "Result")
- Gosub command_run
- }
- If (A_GuiEvent = "Normal" || A_GuiEvent = "I") { ; Single click or selection changed.
- Gosub listviewInfo
- If (lvFullPath <> "Result") {
- ;msgbox %lvFullPath%`n%search_inside%
- If (!search_inside) {
- SB_SetText("Click to copy: " lvFullPath)
- GuiControl enable, addPathButton
- }
- }
- }
- Return
- addPathToSearch: ; Add selected files path to the search box
- GuiControl Focus, command_search ; (shows files in that folder) and do search.
- SendInput %lvDirName%
- Return
- listviewInfo:
- LV_GetText(lvFullPath, A_EventInfo, 1)
- LV_GetText(lvFileName, A_EventInfo, 2)
- LV_GetText(lvDirName, A_EventInfo, 5)
- Return
- GuiContextMenu:
- If (A_GuiControl = "hitlist" && A_GuiControlEvent = "RightClick") ; Only show menu when listview is right clicked.
- {
- Gosub listviewInfo
- Menu Context, Add, Open &directory, menuEvent
- Menu Context, Add
- Menu Context, Add, Open &with %textEditorName%, menuEvent
- Menu Context, Add, &Edit, menuEvent
- Menu Context, Add, &Properties, menuEvent
- Menu Context, Add
- Menu Context, Add, Save &list, menuEvent
- Menu Context, Add
- Menu Context, Add, &Options, menuEvent
- Menu ContextHelp, Add, RegEx Reference, menuEvent
- Menu ContextHelp, Add
- Menu ContextHelp, Add, Everything, menuEvent
- Menu ContextHelp, disable, Everything
- Menu ContextHelp, Add, Home, menuEvent
- Menu ContextHelp, Add, FAQ Searching, menuEvent
- Menu ContextHelp, Add, Wiki Searching, menuEvent
- Menu ContextHelp, Add
- Menu ContextHelp, Add, FindStr Reference, menuEvent
- Menu Context, Add, Help, :ContextHelp
- Menu Context, Show, %A_GuiX%, %A_GuiY%
- Menu Context, Delete
- }
- Return
- menuEvent:
- If ( !ThisMenuItem )
- ThisMenuItem = %A_ThisMenuItem%
- If (ThisMenuItem = "Open &directory")
- Gosub openDirectory
- If (ThisMenuItem = "Open &with "textEditorName)
- Gosub openInTextEditor
- If (ThisMenuItem = "&Edit")
- Gosub editFile
- If (ThisMenuItem = "&Properties")
- Run properties "%lvFullPath%",, UseErrorLevel
- If (ThisMenuItem = "Save &list")
- Gosub saveList
- If (ThisMenuItem = "&Options")
- Gosub app_options
- If (ThisMenuItem = "RegEx Reference")
- Run http://www.regular-expressions.info/
- If (ThisMenuItem = "Home")
- Run http://www.voidtools.com
- If (ThisMenuItem = "FAQ Searching")
- Run http://www.voidtools.com/faq.php#Searching
- If (ThisMenuItem = "Wiki Searching")
- Run http://support.voidtools.com/everything/Searching
- If (ThisMenuItem = "FindStr Reference")
- Run http://technet.microsoft.com/en-us/library/bb490907.aspx
- ThisMenuItem=
- Return
- sbCopyFullPath: ; Sets the timer on for clicking the status bar
- SetTimer copyPath, on ; to copy the selected files full path to clipboard.
- Return
- copyPath:
- If (lvFullPath = "Result") { ; No file selected.
- SB_SetText("Please make a selection first or try again!")
- Sleep 3000
- SB_SetText(progNameSB)
- SetTimer copyPath, off
- Return
- }
- Clipboard = %lvFullPath% ; Path copied.
- SB_SetText("COPIED - - " lvFullPath " - - COPIED") ; Show confirmation.
- Sleep 5000
- SB_SetText("Click to copy: " lvFullPath)
- SetTimer copyPath, off
- Return
- saveList: ; Save the current list of file paths.
- IfNotExist %result_filename% ; No list to save.
- {
- MsgBox Nothing to save!
- Return
- }
- FileSelectFile saveListPath, 16, %A_ScriptDir%\%app_name% - Saved List.txt,, txt ; Select file name and path to save to.
- If (!saveListPath) ; File save cancelled.
- Return
- FileCopy %result_filename%, %saveListPath%
- If ErrorLevel <> 0
- Msgbox There was a problem, list not saved.
- Return
- openDirectory: ; Open selected files folder.
- IfExist %lvDirName%
- Run %fileMan_app% %fileManArgs%"%lvFullPath%", %lvDirName%, UseErrorLevel
- Gosub error_check
- Return
- command_run: ; Run the selected file.
- Run %lvFullPath%, %lvDirName%, UseErrorLevel
- Gosub error_check
- Return
- editFile: ; Edit the file with it's registered program.
- Run Edit %lvFullPath%, %lvDirName%, UseErrorLevel
- Gosub error_check
- Return
- openInTextEditor: ; Open file in a text editor.
- Run %textEditor_app% %lvFullPath%, %lvDirName%, UseErrorLevel
- Gosub error_check
- Return
- error_check: ; If there's an error opening a file, show the reason.
- If (A_LastError <> 0) {
- thisError := returnLastError()
- MsgBox,, %app_name% - Oops ..., %thisError%`nFile: %lvFullPath%
- }
- Return
- app_options: ; Options gui.
- Gui 2:Default
- Gui 2:+Owner +AlwaysOnTop
- Gui 2:Margin, 10, 10
- Gui 2:Add, GroupBox, w400 h90 y+10 section, General
- Gui 2:Add, CheckBox, xs+40 ys+25 vguiChoice checked%guiChoice%, Start with "tabbed" Gui
- Gui 2:Add, CheckBox, xs+240 ys+25 vesSortByPath checked%esSortByPath%, Sort results by full path
- Gui 2:Add, Text, xs+40 yp+35, Maximum results:
- Gui 2:Add, Edit, x+5 w50 r1 vmax_results, %max_results%
- Gui 2:Add, Text, xs+240 yp, Update speed:
- Gui 2:Add, Edit, x+5 w40 r1 vupdate_speed, %update_speed%
- Gui 2:Add, Groupbox, x5 yp+50 w400 h110 section, App Paths
- Gui 2:Add, Text, xs+10 ys+25 w70, Everything:
- Gui 2:Add, Edit, x+5 w300 r1 veverything_app, %everything_app%
- Gui 2:Add, Text, xs+10 yp+25 w70, Es:
- Gui 2:Add, Edit, x+5 w300 r1 vfind_app, %find_app%
- Gui 2:Add, Text, xs+10 yp+25 w70, Findstr:
- Gui 2:Add, Edit, x+5 w300 r1 vfindstr_app, %findstr_app%
- Gui 2:Add, Groupbox, x5 yp+50 w400 h85 section, File Manager
- Gui 2:Add, Text, xs+10 ys+25 w70, Path:
- Gui 2:Add, Edit, x+5 w300 r1 vfileMan_app, %fileMan_app%
- Gui 2:Add, Text, xs+10 yp+25 w70, Arguments:
- Gui 2:Add, Edit, x+5 w100 r1 vfileManArgs, %fileManArgs%
- Gui 2:Add, Groupbox, x5 yp+50 w400 h85 section, Text Editor
- Gui 2:Add, Text, xs+10 ys+25 w70, Path:
- Gui 2:Add, Edit, x+5 w300 r1 vtextEditor_app, %textEditor_app%
- Gui 2:Add, Text, xs+10 yp+25 w70, Editor name:
- Gui 2:Add, Edit, x+5 w300 r1 vtextEditorName, %textEditorName%
- Gui 2:Add, Button, x10 gGui2OK, &Ok
- Gui 2:Add, Button, x+5 gGui2Cancel, &Cancel
- Gui 2:Show,, %app_name% - Options
- Return
- cfgLoad:
- IniRead max_results, %iniPath%, General, MaximumResults, 10000
- IniRead update_speed, %iniPath%, General, UpdateSpeed, 250
- IniRead esSortByPath, %iniPath%, General, SortByPath, 0
- IniRead guiChoice, %iniPath%, General, TabbedGui, 0
- IniRead everything_app, %iniPath%, Paths, EverythingPath, %ProgramFiles%\Everything\Everything.exe
- IniRead find_app, %iniPath%, Paths, EsPath, %ProgramFiles%\Everything\es.exe
- IniRead findstr_app, %iniPath%, Paths, FindStrPath, %A_WinDir%\system32\findstr.exe
- IniRead fileMan_app, %iniPath%, Paths, FileManagerPath, %A_WinDir%\explorer.exe
- IniRead fileManArgs, %iniPath%, Paths, FileManagerPathArgs, `/select`,
- IniRead textEditor_app, %iniPath%, Paths, TextEditorPath, %A_WinDir%\notepad.exe
- IniRead textEditorName, %iniPath%, Paths, TextEditorName, Notepad
- IniRead savedFileSearchQuery, %iniPath%, Strings, FileSearchStrings,
- IniRead savedStringSearchQuery, %iniPath%, Strings, StringSearchStrings,
- Return
- ; C:\Program Files\FreeCommander\FreeCommander.exe /c /l=
- cfgSave:
- IniWrite %max_results%, %iniPath%, General, MaximumResults
- IniWrite %update_speed%, %iniPath%, General, UpdateSpeed
- IniWrite %esSortByPath%, %iniPath%, General, SortByPath
- IniWrite %guiChoice%, %iniPath%, General, TabbedGui
- IniWrite %everything_app%, %iniPath%, Paths, EverythingPath
- IniWrite %find_app%, %iniPath%, Paths, EsPath
- IniWrite %findstr_app%, %iniPath%, Paths, FindStrPath
- IniWrite %fileMan_app%, %iniPath%, Paths, FileManagerPath
- IniWrite %fileManArgs%, %iniPath%, Paths, FileManagerPathArgs
- IniWrite %textEditor_app%, %iniPath%, Paths, TextEditorPath
- IniWrite %textEditorName%, %iniPath%, Paths, TextEditorName
- IniWrite %savedFileSearchQuery%, %iniPath%, Strings, FileSearchStrings
- IniWrite %savedStringSearchQuery%, %iniPath%, Strings, StringSearchStrings
- Return
- Gui2Cancel: ; Close/cancel Options gui.
- 2GuiEscape:
- 2GuiClose:
- Gui 2:Destroy
- Gui 1:Default
- Return
- Gui2OK: ; Save Options
- Gui 2:Submit, Nohide
- Gosub cfgSave
- Gosub Gui2Cancel ; and close gui
- Return
- GuiEscape: ; Close app and delete any temporary files generated.
- GuiClose:
- IfExist %result_filename%
- FileDelete %result_filename%
- IfExist %result_filename2%
- FileDelete %result_filename2%
- IfExist preview.txt
- FileDelete preview.txt
- ExitApp
- Return
- RemoveToolTip:
- ToolTip
- Return
- WM_MOUSEMOVE() {
- static CurrControl, PrevControl, _TT
- CurrControl := A_GuiControl
- If (CurrControl <> PrevControl and not InStr(CurrControl, " ")) {
- ToolTip % %CurrControl%_TT
- SetTimer, RemoveToolTip, 7000
- PrevControl := CurrControl
- }
- }
- returnLastError() {
- Global
- IfEqual A_LastError, 2, Return, "Error " %A_LastError% ": The system cannot find the file specified."
- IfEqual A_LastError, 3, Return, "Error " %A_LastError% ": The system cannot find the path specified."
- IfEqual A_LastError, 4, Return, "Error " %A_LastError% ": The system cannot open the file."
- IfEqual A_LastError, 5, Return, "Error " %A_LastError% ": Access is denied."
- IfEqual A_LastError, 15, Return, "Error " %A_LastError% ": The system cannot find the drive specified."
- IfEqual A_LastError, 21, Return, "Error " %A_LastError% ": The device is not ready."
- IfEqual A_LastError, 25, Return, "Error " %A_LastError% ": Windows cannot find the network path.`nVerify that the network path is correct and the destination computer is not busy or turned off.`nIf Windows still cannot find the network path, contact your network administrator."
- IfEqual A_LastError, 1155, Return, "Error " %A_LastError% ": No application is associated with the specified file for this operation."
- }
- /*
- Everything:
- -r Search the database using a basic POSIX regular expression.
- -i Does a case sensitive search.
- -w Does a whole word search.
- -p Does a full path search.
- -h --help Display this help.
- -n <num> Limit the amount of results shown to <num>.
- -s Sort by full path.
- */
- /*
- Info: http://technet.microsoft.com/en-us/library/bb490907.aspx
- Findstr:
- Searches for strings in files.
- FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F]
- [/C] [/G] [/D] [/A] [/OFF[LINE]]
- strings [[drive][path]filename[ ...]]
- /B Matches pattern if at the beginning of a line.
- /E Matches pattern if at the end of a line.
- /L Uses search strings literally.
- /R Uses search strings as regular expressions.
- /S Searches for matching files in the current directory and all subdirectories.
- /I Specifies that the search is not to be case-sensitive.
- /X Prints lines that match exactly.
- /V Prints only lines that do not contain a match.
- /N Prints the line number before each line that matches.
- /M Prints only the filename if a file contains a match.
- /O Prints character offset before each matching line.
- /P Skip files with non-printable characters.
- /OFF[LINE] Do not skip files with offline attribute set.
- /A:attr Specifies color attribute with two hex digits. See "color /?"
- /F:file Reads file list from the specified file(/ stands for console).
- /C:string Uses specified string as a literal search string.
- /G:file Gets search strings from the specified file(/ stands for console).
- /D:dir Search a semicolon delimited list of directories
- strings Text to be searched for.
- [drive][path]filename Specifies a file or files to search.
- Use spaces to separate multiple search strings unless the argument is prefixed
- with /C. For example, 'FINDSTR "hello there" x.y' searches for "hello" or
- "there" in file x.y. 'FINDSTR /C:"hello there" x.y' searches for
- "hello there" in file x.y.
- The special characters in regular expression syntax are most powerful when you use them together. For example, the following combination of the wildcard character (.) and repeat (*) character match any string of characters:
- .*
- Use the following expression as part of a larger expression that matches any string beginning with "b" and ending with "ing":
- b.*ing
- For full information on FINDSTR regular expressions refer to the online Command
- Reference.
- */
- /*
- http://www.regular-expressions.info/
- */
Add Comment
Please, Sign In to add comment