Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force
- SetworkingDir, %A_workingdir%
- ;#warn
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- FileCreateDir, %A_ScriptDir%\DATA
- FileInstall , CMD.ini, %A_ScriptDir%\DATA\CMD.ini, 1
- FileInstall , CMD.ahk, %A_ScriptDir%\DATA\CMD.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\CMD.ahk, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA\CMD.ini, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA\CMD.txt, 2
- FileSetAttrib +HS, %A_ScriptDir%\DATA, 2
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- SkinForm(Apply, A_ScriptDir . "\DATA\SkinH_EL.dll", A_ScriptDir . "\DATA\S12.she")
- OnExit, GetOut
- Gui,default
- Gui,-DPIScale
- Gui,Color, 091D33, 091D33
- Gui,Font, s12 cDDDDDD, Calibri
- DetectHiddenWindows On
- autotrim,off
- transform,s,chr,32
- transform,q,chr,34
- wa:=A_screenwidth
- ha:=A_screenHeight
- xx:=100
- DllCall("AllocConsole")
- ;DllCall("AttachConsole")
- ;DllCall("AttachConsole", "UInt", pid)
- WinHide % "ahk_id " DllCall("GetConsoleWindow", "ptr")
- ;WinMinimize % "ahk_id " DllCall("GetConsoleWindow", "uint")
- objShell := ComObjCreate("WScript.Shell")
- ;---------------
- gosub,readLB
- ;---------------
- ;-------- saved at Najeeb 2021-12-12 17:36 UTC --------------
- cmdx:="" ;- first command for test
- ;cmdx:="ping www.google.com -n 4"
- ;#warn
- #noenv
- name1:="NAJEEB CMD COMMANDS"
- global name1
- e:=""
- CPX:="cp" . DllCall("GetOEMCP", "UInt") ;- get CODEPAGE e.g. CP850
- x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*13)/xx,h:=(ha*2.8)/xx
- Gui,Add,Button,x%x% y%y% w%w% h%h% gTEST01,GOOGLE-PING
- ;---------------
- x:=(wa*1)/xx,y:=(ha*5)/xx,h:=(ha*56)/xx,w:=(wa*14)/xx
- Gui, Add,Listbox,x%x% y%y% w%w% h%h% vLB1 gLB1,%e1x%
- x:=(wa*16)/xx,y:=(ha*1)/xx,w:=(wa*75)/xx,h:=(ha*60)/xx
- Gui, Add, Edit, x%x% y%y% w%w% h%h% vED1 ;- here the output
- x:=(wa*1)/xx,y:=(ha*63.2)/xx,
- Gui, Add, Text, x%x% y%y%, RUN CMD COMMAND:
- x:=(wa*16)/xx,y:=(ha*63)/xx,w:=(wa*65)/xx,h:=(ha*4)/xx
- Gui, Add, Edit, x%x% y%y% w%w% h%h% vED2,%cmdx% ;- added CMDx command above for test / write command here and then ENTER
- x:=(wa*84)/xx,y:=(ha*63)/xx,w:=(wa*6)/xx,h:=(ha*3.2)/xx
- Gui, add, Edit, x%x% y%y% w%w% h%h% vED3, ;- write ENDED when command finished
- x:=(wa*1)/xx,y:=(ha*69)/xx,w:=(wa*6)/xx,h:=(ha*3.2)/xx
- Gui,add,button, x%x% y%y% w%w% h%h% gPrintx, PRINT ;- write to file last commands and outputs
- x:=(wa*10)/xx,y:=(ha*69)/xx,w:=(wa*6)/xx,h:=(ha*3)/xx
- Gui,Add, Button, x%x% y%y% w%w% h%h% gSAVE,SAVE
- x:=(wa*2)/xx,y:=(ha*2)/xx,w:=(wa*92)/xx,h:=(ha*75)/xx
- Gui, Show,x%x% y%y% w%w% h%h%,%name1%
- gosub,a0
- GuiControl,1: Focus,ED2
- ;send,^{end}
- return
- ;-------------------------
- Guiescape:
- Guiclose:
- DllCall("FreeConsole")
- sleep,200
- exitapp
- ;---------------------
- test01:
- gosub,ping
- return
- ;----------------------------------------------
- ping:
- Gui,1:submit,nohide
- objExec := objShell.Exec("cmd /c ping -n 3 -w 1000 www.google.com")
- output:=""
- while,!objExec.StdOut.AtEndOfStream
- {
- GuiControlGet,ED1
- ;-----------------------------------------
- output.=objExec.StdOut.readline() . "`n"
- ;-----------------------------------------
- GuiControl,1:,ED1,%output%
- }
- ;GuiControl,1:,ED1,%output%
- output=
- return
- ;-------------------------
- ~$enter::
- gosub,a0
- return
- ;=========================================================
- AddOutputInGui(output) {
- Control, EditPaste, %output%`r`n, Edit1,%name1% ;- display output in 1st EDIT
- }
- ;=========================================================
- A0:
- Gui,1:submit,nohide
- ed2a:="cmd /c " . ed2
- ;CmdRet(ED1a, Func("AddOutputInGui"),CPX)
- xxc:=cmdret(ED2a, Func("AddOutputInGui"),CPX)
- e .="`r`n===============================`r`n" . ed1 . " =`r`n-------------------------------`r`n" . xxc . "`r`n===============================`r`n"
- e := RegExReplace(e, "((^)|\R)\h*(?=\R|$)(?(2)\R)") ;- remove empty lines
- gosub,clear
- return
- ;-------------------------
- CLEAR:
- Gui,1:submit,nohide
- Guicontrol,1:,ED2,
- Guicontrol,1:,ED3,ENDED
- GuiControl,1: Focus,ED2
- return
- ;-------------------------
- printx:
- f1=%a_desktop%\%a_now%_DOS_SCREEN_OUTPUT.txt
- Gui,1:submit,nohide
- if e<>
- {
- fileappend,%e%,%f1%,utf-8
- run,%f1%
- e:=""
- }
- return
- ;-------------------------
- SAVE:
- Gui,submit,nohide
- Clipboard := ED1
- ClipWait ; Wait for the clipboard to contain text.
- FileAppend, %clipboard% , %A_desktop%\SaveCmd.txt
- Return
- ;=========================================================
- CmdRet(sCmd, callBackFuncObj := "", encoding := "CP0")
- {
- static HANDLE_FLAG_INHERIT := 0x00000001, flags := HANDLE_FLAG_INHERIT
- , STARTF_USESTDHANDLES := 0x100, CREATE_NO_WINDOW := 0x08000000
- hPipeRead:=""
- hPipeWrite:=""
- sOutput:=""
- DllCall("CreatePipe", "PtrP", hPipeRead, "PtrP", hPipeWrite, "Ptr", 0, "UInt", 0)
- DllCall("SetHandleInformation", "Ptr", hPipeWrite, "UInt", flags, "UInt", HANDLE_FLAG_INHERIT)
- VarSetCapacity(STARTUPINFO , siSize := A_PtrSize*4 + 4*8 + A_PtrSize*5, 0)
- NumPut(siSize , STARTUPINFO)
- NumPut(STARTF_USESTDHANDLES, STARTUPINFO, A_PtrSize*4 + 4*7)
- NumPut(hPipeWrite , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*3)
- NumPut(hPipeWrite , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*4)
- VarSetCapacity(PROCESS_INFORMATION, A_PtrSize*2 + 4*2, 0)
- if !DllCall("CreateProcess", "Ptr", 0, "Str", sCmd, "Ptr", 0, "Ptr", 0, "UInt", true, "UInt", CREATE_NO_WINDOW
- , "Ptr", 0, "Ptr", 0, "Ptr", &STARTUPINFO, "Ptr", &PROCESS_INFORMATION)
- {
- DllCall("CloseHandle", "Ptr", hPipeRead)
- DllCall("CloseHandle", "Ptr", hPipeWrite)
- throw Exception("CreateProcess is failed")
- }
- DllCall("CloseHandle", "Ptr", hPipeWrite)
- VarSetCapacity(sTemp, 4096), nSize := 0
- while DllCall("ReadFile", "Ptr", hPipeRead, "Ptr", &sTemp, "UInt", 4096, "UIntP", nSize, "UInt", 0) {
- sOutput .= stdOut := StrGet(&sTemp, nSize, encoding)
- ;sOutput .= stdOut := StrGet(&sTemp, nSize)
- ;sOutput .= stdOut := StrGet(&sTemp, nSize, CPX)
- ( callBackFuncObj && callBackFuncObj.Call(stdOut) )
- }
- DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION))
- DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION, A_PtrSize))
- DllCall("CloseHandle", "Ptr", hPipeRead)
- Return sOutput
- }
- ;==================== DOS HELP ================
- lb1:
- gui,submit,nohide
- GuiControl,1:,ED1,
- lb1=%lb1%
- stringmid,pingx,lb1,1,4
- if (lb1="ping /?")
- {
- gosub,exec
- return
- }
- if (pingx="ping")
- {
- ;gosub,ping
- return
- }
- ;- run#xxx
- stringmid,lb1a,lb1,1,1
- if (lb1a="#")
- {
- stringtrimleft,lb1,lb1,1
- try {
- run,%lb1%
- } catch {
- erl:= errorlevel
- msgbox, 262208,ERROR,Not found =%lb1%`nERROR=%erl%
- }
- return
- }
- ;------ change directories and open folder ----
- if lb1 contains % "cd "
- {
- k1:=""
- k2:=""
- stringsplit,k,lb1,`;,
- stringmid,str1,k2,1,2
- if (str1="::")
- {
- run, "%k2%"
- return
- }
- if k2<>
- {
- run,%k2%
- return
- }
- ;gosub,exec
- return
- }
- gosub,exec
- return
- exec:
- objExec := objShell.Exec(ComSpec " /c " . lb1 . "`n")
- cl:=""
- while, !objExec.StdOut.AtEndOfStream
- cl:= objExec.StdOut.ReadAll()
- GuiControl,1:,ED1,%Cl%
- cl:=""
- return
- ;-----------------------------------------------
- ;----------------------------------------------
- readLB:
- ;--------------------- DOS commands -----
- fcdm=%a_scriptdir%\DATA\CMD.txt
- ifnotexist,%fcdm%
- runwait,%comspec% /c help >"%fcdm%",,hide,
- ;-----------------------------------------
- i=0
- e1x:=""
- e1x =
- (Ltrim Join|
- HELP /?
- TYPE CMD.ini
- #charmap
- #notepad
- #calc
- #winver
- #vlc
- cd MyDocuments ;%a_mydocuments%
- cd Desktop ;%A_desktop%
- cd MyComputer ;::{20d04fe0-3aea-1069-a2d8-08002b30309d}
- cd MyNetworkPlaces ;::{208d2c60-3aea-1069-a2d7-08002b30309d}
- cd NetworkConnections ;::{7007acc7-3202-11d1-aad2-00805fc1270e}
- cd Printers ;::{2227a280-3aea-1069-a2de-08002b30309d}
- cd RecycleBin ;::{645ff040-5081-101b-9f08-00aa002f954e}
- cd Appdata ;%a_appdata%
- cd Appdatacommon ;%a_appdatacommon%
- cd Programfiles ;%a_programfiles%
- cd Programs ;%a_programs%
- cd ProgramsCommon ;%a_programsCommon%
- cd StartMenu ;%a_StartMenu%
- cd StartMenuCommon ;%a_StartMenuCommon%
- cd Startup ;"C:\Users\Najeeb\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
- cd StartupCommon ;%a_StartupCommon%
- cd Windows ;%a_windir%
- cd Temp ;%a_temp%
- cd WorkingDir ;%a_workingdir%
- cd Script ;notepad "%a_scriptfullpath%"
- cd ScriptDir ;%a_scriptdir%
- cls
- ping /?
- ping -n 4 -w 1000 www.google.com
- netstat -an
- netstat -e -s
- netstat
- ipconfig /?
- ipconfig
- ipconfig /all
- dir
- dir /S /B /A
- dir /P /Q /L /4 /TAWC
- dir /?
- help
- cmd /?
- magick -help
- ffmpeg -h
- TZUTIL /L
- TZUTIL /G
- TZUTIL /S "Pakistan Standard Time"
- where /?
- where /r D:\ *.exe
- wget -h
- ver
- vol
- date /t
- time /t
- Path /?
- )
- fileread,a,%fcdm% ;- textfile is in variable A
- loop,parse,a,`n,`r ;- parse each line
- {
- i++
- if (i<3) ;- remove at least the first two lines from help
- continue
- y1=%a_loopfield%
- stringmid,y2,y1,1,3
- if (y1="" or y2=" ")
- {
- y1=
- y2=
- continue
- }
- c1=
- stringsplit,c,y1,%s%
- if (c1="dir" or c1="ver" or c1="path" or c1="chcp")
- e1x .= c1 . "|"
- e1x .= c1 . " /?|"
- }
- a=
- 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