Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force
- SetworkingDir, %A_workingdir%
- ;- modified = 20210405
- ;- created = 20210324
- ;------------------------------------
- ;- cmdret user teadrinker / added a GUI with listbox and edit
- ;- https://www.autohotkey.com/boards/viewtopic.php?p=392095#p392095 / 20210405
- ;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=84266&sid=eff012cadb7a851b2c18f5f03b68408f / 20201210
- #warn
- FileEncoding , UTF-8
- ;- https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
- ;- https://docs.microsoft.com/en-au/windows/win32/shell/knownfolderid
- ;- https://docs.microsoft.com/en-au/windows/win32/shell/csidl
- setworkingdir,%a_scriptdir%
- Gui,2:default
- ;Gui,2: -Caption +LastFound +AlwaysOnTop
- Gui,2: -DPIScale
- Gui,2:color,black,black
- Gui,2:Font,s12 cYellow,Lucida Console
- DetectHiddenWindows On
- autotrim,off
- transform,s,chr,32
- dlm:=";"
- e1x:=""
- wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
- name1:="Najeeb CMD Commands"
- global name1
- ;- https://ss64.com/nt/chcp.html
- CPX:="cp" . DllCall("GetOEMCP", "UInt") ;- get CODEPAGE e.g. CP850
- fcdm=%a_scriptdir%\doscommands_small_02.txt
- ;---------------
- gosub,readLB
- ;---------------
- cmdx=ver
- x:=(wa*1)/xx ,y:=(ha*1)/xx,h:=(ha*3.0)/xx,w:=(wa*67)/xx
- Gui,2:Add,Edit,x%x% y%y% w%w% h%h% vED0 ,%cmdx% ;- command
- ;---------------------------------------------------------
- x:=(wa*68.5)/xx ,y:=(ha*1)/xx,h:=(ha*2.6)/xx,w:=(wa*5)/xx
- Gui,2:Add,Button,x%x% y%y% w%w% h%h% gA0 default,<RUN ;- GO
- ;---------------------------------------------------------
- x:=(wa*74)/xx,y:=(ha*1)/xx,w:=(wa*5.5)/xx,h:=(ha*2.5)/xx
- Gui,2: add, Edit, x%x% y%y% w%w% h%h% center vED5, ;- display "Ended"
- ;----------------------- LISTBOX -------------------------
- x:=(wa*1)/xx ,y:=(ha*4)/xx,h:=(ha*90)/xx,w:=(wa*10)/xx
- Gui,2:Add,Listbox,x%x% y%y% w%w% h%h% vLB1 gLB1,%e1x% ;- Listbox
- ;---------------------------------------------------------
- x:=(wa*12)/xx,y:=(ha*4)/xx,h:=(ha*90)/xx,w:=(wa*68)/xx
- Gui,2:Add,Edit, x%x% y%y% h%h% w%w% vED1 cYellow, ;- show "result text"
- ;---------------------------------------------------------
- x:=(wa*12)/xx,y:=(ha*.1)/xx,h:=(ha*95)/xx,w:=(wa*80)/xx
- Gui,2:Show, x%x% y%y% w%w% h%h% ,%name1%
- GuiControl,2: Focus,ED0
- send,{end}
- return
- ;----------------------------------------------
- 2Guiescape:
- 2Guiclose:
- exitapp
- ;----------------------------------------------
- ;=========================================================
- AddOutputInGui(output) {
- Control, EditPaste, %output%`r`n, Edit3,%name1% ;- display output in EDIT ( show "result text" )
- }
- ;=========================================================
- lb1:
- gui,2:submit,nohide
- h1:=""
- h2:=""
- stringsplit,h,lb1,%dlm%
- if h2<>
- {
- ed0=%h2%
- Guicontrol,2:,ED0,%ed0%
- sleep,500
- gosub,a0a
- }
- return
- ;--------
- A0:
- Gui,2:submit,nohide
- A0a:
- ControlSend,Edit3,======= %ed0% ========`r`n,%name1%
- Guicontrol,2:,ED5
- ed2a:=comspec . " /c " . ed0
- CmdRet(ED2a, Func("AddOutputInGui"),CPX)
- gosub,clear
- return
- ;-------------------------
- CLEAR:
- Gui,2:submit,nohide
- Guicontrol,2:,ED0,
- Guicontrol,2:,ED5,ENDED
- GuiControl,2: Focus,ED0
- return
- ;----------------------------------------------
- readLB:
- Gui,2:submit,node
- ;- chcp 1252 West European Latin DOS_Commands for german help UMLAUT
- ifnotexist,%fcdm%
- runwait,%comspec% /c chcp 1252&help >"%fcdm%",,hide
- i=0
- e1x:=""
- ;- add some other commands to variable e1x , example for youtube-dl :
- ;- youtube-dl ;C:\Users\GARRY\Desktop\PROJECT\YT_DL_TEST\youtube-dl.exe https://www.youtube.com/watch?v=G6_DldYj0uQ --verbose --youtube-skip-dash-manifest --write-auto-sub --sub-lang en -o C:\Users\GARRY\Desktop\M_VIDEO\`%(title)s$`%(uploader)s$`%(id)s.`%(ext)s
- e1x:="
- (Ltrim Join|
- version ;ver
- systeminfo ;systeminfo
- CMD-ALL ;TYPE DATA\CMD.fm
- CMD-COMMAND ;TYPE DATA\CMD.ls
- CMD-ALL2 ;TYPE DATA\ALL.ls
- CMD-ATTRIB ;TYPE DATA\ATTRIB.ls
- CMD-COPY ;TYPE DATA\COPY.ls
- CMD-DEL ;TYPE DATA\DEL.ls
- CMD-DIR ;TYPE DATA\DIR.ls
- CMD-FIND ;TYPE DATA\FIND.ls
- CMD-HELP ;TYPE DATA\HELP.ls
- CMD-MD ;TYPE DATA\MD.ls
- CMD-NET ;TYPE DATA\NET.ls
- CMD-NIR ;TYPE DATA\NIR.ls
- CMD-REN ;TYPE DATA\REN.ls
- CMD-start ;TYPE DATA\START.ls
- youtube-dl update ;youtube-dl -U ; TEST youtube-dl must be in a_scriptdir otherwise use fullpath
- youtube-dl help ;youtube-dl --help
- netstat -an ;netstat -an
- netstat -e -s ;netstat -e -s
- netstat /? ;netstat /?
- ipconfig /? ;ipconfig /?
- ipconfig ;ipconfig
- ipconfig /all ;ipconfig /all
- dir /P /Q /L /4 /TAWC ;dir /P /Q /L /4 /TAWC
- help ;help
- date&time ;date /t&time /t
- time /t ;time /t
- RESTORE rstrui ;rstrui
- ping autohotkey 3x ;ping -n 3 -w 3000 autohotkey.com
- ping /? ;ping /?
- =======================;date /t&time /t
- "
- )
- fileread,a,%fcdm%
- loop,parse,a,`n,`r ;- parse each line
- {
- i++
- if (i<4) ;- remove at least the first 3 lines from help
- continue
- y1=%a_loopfield%
- if y1=
- break ;- at last line which is empty , then finish
- 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 . " " . dlm . c1 . "|"
- e1x .= c1 . " /? " . dlm . c1 . " /?|"
- }
- a=
- return
- ;========================= function teadrinker 20210405 ==========================================
- ;-https://www.autohotkey.com/boards/viewtopic.php?p=392095#p392095
- CmdRet(sCmd, callBackFunc := "", encoding := "")
- {
- static flags := [HANDLE_FLAG_INHERIT := 0x1, CREATE_NO_WINDOW := 0x8000000], STARTF_USESTDHANDLES := 0x100
- (encoding = "" && encoding := "cp" . DllCall("GetOEMCP", "UInt"))
- hPipeRead:=""
- hPipeWrite:=""
- sOutput:=""
- DllCall("CreatePipe", "PtrP", hPipeRead, "PtrP", hPipeWrite, "Ptr", 0, "UInt", 0)
- DllCall("SetHandleInformation", "Ptr", hPipeWrite, "UInt", flags[1], "UInt", flags[1])
- VarSetCapacity(STARTUPINFO , siSize := A_PtrSize*9 + 4*8, 0)
- NumPut(siSize , STARTUPINFO)
- NumPut(STARTF_USESTDHANDLES, STARTUPINFO, A_PtrSize*4 + 4*7)
- NumPut(hPipeWrite , STARTUPINFO, siSize - A_PtrSize*2)
- NumPut(hPipeWrite , STARTUPINFO, siSize - A_PtrSize)
- VarSetCapacity(PROCESS_INFORMATION, A_PtrSize*2 + 4*2, 0)
- if !DllCall("CreateProcess", "Ptr", 0, "Str", sCmd, "Ptr", 0, "Ptr", 0, "UInt", true, "UInt", flags[2]
- , "Ptr", 0, "Ptr", 0, "Ptr", &STARTUPINFO, "Ptr", &PROCESS_INFORMATION)
- {
- DllCall("CloseHandle", "Ptr", hPipeRead)
- DllCall("CloseHandle", "Ptr", hPipeWrite)
- throw "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)
- ( callBackFunc && %callBackFunc%(stdOut) )
- }
- DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION))
- DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION, A_PtrSize))
- DllCall("CloseHandle", "Ptr", hPipeRead)
- Return sOutput
- }
- #R::Reload
- #S::Suspend
- #P::Pause
- ESC::ExitApp
- ;================= END SCRIPT ================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement