iahngy Posted February 28, 2014 Share Posted February 28, 2014 I m still confused how to make this DOS window work with series of command entering using StdinWrite($DOS, 'dir/whatever' & @CRLF) instead of using button .. how to update the edit /dos window after that and to read the output from dos. Mine doesn't work yet ..Would you give me some hints. Link to comment Share on other sites More sharing options...
iahngy Posted February 28, 2014 Share Posted February 28, 2014 I noticed when I use only stdin_child option , it shows the dos output on the Autoit console. $DOS = Run('"' & @ComSpec & '"', '', @SW_HIDE, $STDIN_CHILD ) StdinWrite($DOS, 'dir' & @CRLF) Link to comment Share on other sites More sharing options...
Gianni Posted March 1, 2014 Share Posted March 1, 2014 I m still confused how to make this DOS window work with series of command entering using StdinWrite($DOS, 'dir/whatever' & @CRLF) instead of using button .. how to update the edit /dos window after that and to read the output from dos. Mine doesn't work yet ..Would you give me some hints. something like this could do, be aware that if you send an "endless" dos command (example: ping localhost -t), the sub will never return back expandcollapse popup#include <WindowsConstants.au3> #include <Constants.au3> #include <GuiEdit.au3> Global $DOS = Run(@ComSpec & " /K", "", @SW_HIDE, $STDERR_MERGED + $STDIN_CHILD) ; run in background an hidden cmd $hGUI = GUICreate("Command Prompt", 600, 326) $hEdit = GUICtrlCreateEdit('', 0, 0, 600, 297, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_WANTRETURN, $ES_READONLY)) GUICtrlSetFont(-1, 10, 400, 0, "Lucida Console") GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0x00FF00) ; Text color green GUISetState(@SW_SHOW) ; ----------------------------- MsgBox(0, "Output", Dos("dir")) $result = Dos("ping " & @ComputerName) MsgBox(0, "Output", $result) ; ----------------------------- Func Dos($cmd) Local $tail = '' ; clear tail Switch $cmd Case "exit" ; StdinWrite($DOS, 'Exit' & @CRLF) ; ProcessWaitClose($DOS) Return "exit not allowed" Case "cls" ; clear screen using cls GUICtrlSetData($hEdit, '') Return "" EndSwitch StdinWrite($DOS, $cmd & @CRLF) ; send dos command While 1 $Stdout = StdoutRead($DOS) ; get output from command If @extended Then ; if there is output then $tail &= $Stdout ; add to tail ; read edit ctrl $sEdit = GUICtrlRead($hEdit) ; limit size in edit to prevent reaching full limit If StringLen($sEdit) > 15000 Then GUICtrlSetData($hEdit, StringRight($sEdit, 15000)) ; leave only last 15000 chars of "buffer" EndIf GUICtrlSetData($hEdit, $Stdout, True) ; append stdout to edit ctrl ElseIf StringRight($tail, 1) = '>' Then Return StringStripWS(StringMid(StringLeft($tail, StringInStr($tail, @CR, 0, -1)), StringInStr($tail, @CR, 0, 1)), 3) EndIf WEnd EndFunc ;==>Dos guiltyking 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
iahngy Posted March 1, 2014 Share Posted March 1, 2014 PincoPanco, thank you very much. It works awesomely. I ll use this to run some perl script on Dos window and read output from them .. I didn't know it needs a loop for reading the stdoutput hehe. I used std write and then read right after ..it never shows any result..Thnks again for your wonderful help Link to comment Share on other sites More sharing options...
Gianni Posted March 1, 2014 Share Posted March 1, 2014 (edited) PincoPanco, thank you very much. It works awesomely. I ll use this to run some perl script on Dos window and read output from them .. I didn't know it needs a loop for reading the stdoutput hehe. I used std write and then read right after ..it never shows any result..Thnks again for your wonderful help You are welcome p.s. take a look also to some >other ways to use cmd edit: also here Edited March 1, 2014 by PincoPanco Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
iahngy Posted March 2, 2014 Share Posted March 2, 2014 (edited) how can I exit out of the current process of a dos command without losing the main dos window? for example I ran a bat file to set up a profile ...this normally takes 7 min or longer until it shows up the promt > ..and I wnt to ends it for something else? Edited March 2, 2014 by iahngy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now