Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* INFO
- NAJEEB SEARCH TEXT UTILITY 2023
- Written by: Najeeb Shah Khan (najeebshahkhan@gmail.com)
- Last Modified: 3-25-2023
- */
- ;#warn
- #NoEnv
- #LTrim
- #SingleInstance, Force
- Process, Priority, , A
- SendMode, Input
- SetBatchLines, -1
- ;#NoTrayIcon
- SetKeyDelay 0 ; In case SendInput is not available
- SetTitleMatchMode RegEx
- SetWorkingDir %A_WorkingDir% ;%A_ScriptDir%
- ;FileSelectFile, SelectedFile, 3, ,
- ;FileRead, MyCMD, %SelectedFile%
- FileCreateDir, %A_ScriptDir%\DATA
- FileInstall , SEARCH-TEXT2.ahk, %A_ScriptDir%\DATA\SEARCH-TEXT2.ahk, 1
- FileInstall , S12.she, %A_ScriptDir%\DATA\S12.she, 1
- FileInstall , SkinH_EL.dll, %A_ScriptDir%\DATA\SkinH_EL.dll, 1
- FileSetAttrib +HS, %A_ScriptDir%\DATA\S12.she, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA\SkinH_EL.dll, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA\SEARCH-TEXT2.ahk, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- SkinForm(Apply, A_ScriptDir . "\DATA\SkinH_EL.dll", A_ScriptDir . "\DATA\S12.she")
- OnExit, GetOut
- Gui,Color, 091D33, 091D33
- Gui,Font, s16 cDDDDDD, Calibri
- Gui,Add,Text,X50 Y7, ~~~************ NAJEEB SEARCH TEXT UTILITY 2023************~~~
- Gui,Font, s14 cDDDDDD, Calibri
- Gui, Add, ListBox, x10 y38 h550 w700 vresults gClip,
- Gui,Add,Text,X10 Y603,SEARCH TEXT
- Gui, Add, Edit, x120 y600 w480 vneedle grefresh,
- listboxvisible := true
- Gui, Add, Button,gBrowse x616 y600 w90 h30 , Browse
- Gui, Show, w720 h650, NAJEEB SEARCH A TEXT
- GuiControl, Focus, needle
- Return
- ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Browse:
- FileSelectFile, SelectedFile, 3, , Open a file
- FileRead, FileContents, %SelectedFile%
- Sort, FileContents
- Return
- Refresh:
- Gui, Submit, NoHide ; Save the user's input without hiding the window
- choicelimit := 0 ; resets the listbox choices counter every time the user adds or removes a letter from the edit box
- GuiControl,, results, | ; this empties the previous listbox entries
- listbox:="" ; this empties variable that controls the listbox entries
- if (needle != "") ; if the user's entry isn't empty (if something typed into editbox)
- {
- Guicontrol, show, results ; show the listbox
- listboxvisible := true
- Loop, parse, FileContents, `n, `r ; parse the wordlist.txt in memory to find matches
- {
- haystack:=A_LoopField ; cycles each line 1 by 1 matching 1 word at a time
- position := instr(haystack, needle) ; finds out where the user's entry matches the word at (left, middle, or end of word etc.) or if not at all
- if (position = 1) ;if it matches from the left
- {
- listbox.="|" . haystack ; add it to the listbox variable
- choicelimit := choicelimit + 1 ; increase the counter which counts how many results are going to be in the listbox
- }
- }
- Loop, parse, FileContents, `n, `r ; parse the wordlist.txt in memory again for a different kind of matching (midstring match)
- {
- haystack:=A_LoopField ; cycles each line 1 by 1 matching 1 word at a time
- position := instr(haystack, needle) ; finds out where the user's entry matches the word at (left, middle, or end of word etc.) or if not at all
- if (position > 1) ; if it matches anywhere but from the left
- {
- listbox.="|" . haystack ; add it to the listbox variable, importantly AFTER the above matches
- choicelimit := choicelimit + 1 ; increase the counter which counts how many results are going to be in the listbox
- }
- }
- if (listbox = "" || listbox = "|") {
- listboxvisible := false
- return
- }
- GuiControl,, results, %listbox% ; add the matched words to the listbox entries
- GuiControl, choose, results, 1 ; choose the first one by default (highlight it)
- resultchosen := 1 ; store which choice is highlighted in a variable
- }
- return
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- GetOut:
- ;GuiClose:
- Gui, Hide
- SkinForm(0)
- ExitApp
- return
- SkinForm(Param1 = "Apply", DLL = "", SkinName = ""){
- if(Param1 = Apply){
- DllCall("LoadLibrary", str, DLL)
- DllCall(DLL . "\SkinH_AttachEx", AStr,SkinName, Str,"mhgd")
- }else if(Param1 = 0){
- DllCall(DLL . "\USkinExit")
- }
- }
- Clip:
- Gui, Submit, NoHide
- Clipboard := results
- Return
- ;=-=-=-=-=-=-=-=-=-=- END SCRIPT -=-=-=-=-=-=-=-=-=-=-=-
- #R::Reload
- #S::Suspend
- #P::Pause
- ESC::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement