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, , Open a file
- FileRead, FileContents, %SelectedFile%
- ;Sort, FileContents
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- FileCreateDir, %A_ScriptDir%\DATA
- FileInstall , SEARCH-TEXT3.ahk, %A_ScriptDir%\DATA\SEARCH-TEXT3.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-TEXT3.ahk, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- SkinForm(Apply, A_ScriptDir . "\DATA\SkinH_EL.dll", A_ScriptDir . "\DATA\S12.she")
- OnExit, GetOut
- Gui 1:Color, 091D33, 091D33
- Gui 1:Font, s16 cDDDDDD, Calibri
- Gui 1:Add,Text,X50 Y7, ~~~************ NAJEEB SEARCH TEXT UTILITY 2023************~~~
- Gui 1:Font, s12 cDDDDDD, Calibri
- Gui 1:Add, Button, x10 y45 gFindString, SEARCH TEXT
- Gui 1:Add, Edit, x130 y47 w565 vfind
- Gui 1:Add, Edit, x10 y85 w700 r28 vcontent HSCROLL, %FileContents%
- Gui 1:Add, StatusBar,, Type the search string to look for and click the Search-button
- ;SB_SetParts(300)
- Gui 1:Show, w720 h672, FindSample
- WinGet ControlID, ID, FindSample
- FindString:
- Gui, Submit, Nohide
- if (find != lastFind) {
- offset = 0
- hits = 0
- }
- GuiControl 1:Focus, Content ; focus on main help window to show selection
- SendMessage 0xB6, 0, -999, Edit2, ahk_id %ControlID% ; Scroll to top
- StringGetPos pos, Content, %find% ,,offset ; find the position of the search string
- if (pos = -1) {
- if (offset = 0) {
- SB_SetText("'" . find . "' not found", 1)
- SB_SetText("", 2)
- }
- else {
- SB_SetText("No more occurrences of '" . find . "'")
- SB_SetText("", 2)
- offset = 0
- hits = 0
- }
- return
- }
- StringLeft __s, Content, %pos% ; cut off end to count lines
- StringReplace __s,__s,`n,`n,UseErrorLevel ; Errorlevel <- line number
- addToPos=%Errorlevel%
- SendMessage 0xB6, 0, ErrorLevel, Edit2, ahk_id %ControlID% ; Scroll to visible
- SendMessage 0xB1, pos + addToPos, pos + addToPos + Strlen(find), Edit2, ahk_id %ControlID% ; Select search text
- ; http://msdn.microsoft.com/en-us/library/bb761637(VS.85).aspx
- ; Scroll the caret into view in an edit control:
- SendMessage, EM_SCROLLCARET := 0xB7, 0, 0, Edit2, ahk_id %ControlID%
- offset := pos + addToPos + Strlen(find)
- lastFind = %find%
- hits++
- SB_SetText("'" . find . "' found in line " . addToPos + 1, 1)
- SB_SetText(hits . (hits = 1 ? " hit" : " hits"), 2)
- 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