Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* INFO
- NAJEEB CMD COMMAND UTILITY
- Written by: Najeeb Shah Khan (najeebshahkhan@gmail.com)
- Last Modified: 3-25-2023
- */
- #Persistent
- SetTitleMatchMode, 2
- #NoEnv
- ; #Warn
- ;~ SendMode Input
- SetWorkingDir %A_ScriptDir%
- FileCreateDir, %A_ScriptDir%\DATA
- FileInstall , CMD.txt, %A_ScriptDir%\DATA\CMD.txt, 1
- FileInstall , CMD2.ahk, %A_ScriptDir%\DATA\CMD2.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\CMD2.ahk, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA\CMD.txt, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- ;FileRead,FileContents,CMD.ls
- FileRead, MyCMD, %A_ScriptDir%\DATA\CMD.txt
- FileRead, FileContents, %A_ScriptDir%\DATA\CMD.txt
- Sort, FileContents
- ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- global Folder := A_ScriptDir
- global ScriptFolder := A_ScriptDir
- DetectHiddenWindows,On
- Run,%ComSpec% /k,,Hide UseErrorLevel,pid
- if not ErrorLevel
- {
- while !WinExist("ahk_pid" pid)
- Sleep,10
- DllCall("AttachConsole","UInt",pid)
- }
- SkinForm(Apply, A_ScriptDir . "\DATA\SkinH_EL.dll", A_ScriptDir . "\DATA\S12.she")
- OnExit, GetOut
- Gui,Color, 091D33, 091D33
- Gui,Font, s14 cDDDDDD, Calibri
- Gui,2:Color, 091D33, 091D33
- Gui,2:Font, s14 cDDDDDD, Calibri
- Gui,Add,Text,X20 Y10, NAJEEB CMD COMMANDS WINDOES
- Gui,2:Add,Text,X20 Y10, ALL COMMANDS
- Gui,Font, s12 cDDDDDD, Calibri
- Gui,Add,Edit,X10 Y40 W600 H500 vText
- ;Gui,2:Add,Edit,X2 Y40 W380 H590 vTcmd, %FileContents%
- Gui,2:Add, listbox, x2 y40 h555 w380 vresults gClip,
- Gui,2:Add,Text,X10 Y602, SEARCH
- Gui,2:Add, Edit, x90 y600 w290 vneedle grefresh,
- listboxvisible := true
- Gui, Add, Button,X10 Y550 gCFloder,Change Folder
- Gui, Add, Button,X140 Y550 gSFloder,Start Folder
- Gui, Add, Button,X240 Y550 gShowHide vShowHide , Show/Hide More
- Gui, Add, Button, X370 Y550 gSave,SAVE TEXT
- Gui,Add,Button, X10 Y600 Default gCommand,Command Run
- Gui,Add,Edit,X140 Y602 w470
- Gui,Show,w620 H620 Autosize, CLI
- Gui,2:Show,w420 H620 Autosize, CMD
- GuiControl,2:Focus, needle
- WinWait, CLI
- WinMove, CLI,,5, 10, 620, 670
- WinWait, CMD
- WinMove, CMD,, 636, 10, 390, 670
- Send, {Tab}
- Send, {Tab}
- Send, {Tab}
- Send, {Tab}
- return
- Command:
- outvar := ""
- Gui, Show
- ControlSetText, Edit1
- ControlGetText, outvar, Edit2
- objShell:=ComObjCreate("WScript.Shell")
- ObjShell.CurrentDirectory := Folder
- mydir := objShell.CurrentDirectory
- CMD := "%ComSpec% /c "outvar
- objExec:=objShell.Exec(CMD)
- ControlSetText, Edit2, Please wait ...
- while,!objExec.StdOut.AtEndOfStream
- {
- GuiControlGet,Text
- strStdOut:=objExec.StdOut.ReadAll()
- GuiControl,,Edit1,%Text%`r`n%strStdOut%`r`n%mydir%>
- }
- objShell:=""
- ObjExec:=""
- ControlSetText, Edit2
- Gui, Show
- Return
- CFloder:
- ;~ objShell:=ComObjCreate("WScript.Shell")
- FileSelectFolder, NewFolder, , 3
- If NewFolder =
- MsgBox,,, No Folder selected.,1
- Else {
- NewFolder := RegExReplace(NewFolder, "\\$") ; Removes the trailing backslash, if present.
- objShell.CurrentDirectory := NewFolder
- Folder := NewFolder
- ;msgbox, , , Changed folders to %Folder%, 2
- }
- objShell:=""
- ObjExec:=""
- ControlSetText, Edit1, , ahk_exe AutoHotkey.exe
- ControlSetText, Edit1, %Folder%>, ahk_exe AutoHotkey.exe
- ControlFocus, Edit2, ahk_exe Autohotkey.exe
- return
- SFloder:
- ;objShell:=ComObjCreate("WScript.Shell")
- Folder := ScriptFolder
- ;msgbox, , , Changed folders to %ScriptFolder%, 2
- objShell:=""
- ObjExec:=""
- ControlSetText, Edit1
- sleep, 10
- ControlSetText, Edit1, %Folder%>, ahk_exe AutoHotkey.exe
- ControlFocus, Edit2, ahk_exe Autohotkey.exe
- return
- ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- ShowHide:
- if hidden {
- GuiControl, 2:Show, CMD
- GuiControl, Show, CLI
- }
- else {
- GuiControl, 2:Hide, CMD
- GuiControl, Hide, CLI
- }
- hidden:=not hidden
- return
- GuiClose:
- ButtonCancel:
- ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Save:
- Gui, submit, nohide
- FileAppend, `n%Text%, %A_Desktop%\SaveText.txt
- 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
- Clip:
- Gui, Submit, NoHide
- Clipboard := results
- 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")
- }
- }
- ;=-=-=-=-=-=-=-=-=-=- END SCRIPT -=-=-=-=-=-=-=-=-=-=-=-
- #R::Reload
- #S::Suspend
- #P::Pause
- ESC::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement