#include <Constants.au3>
#include <WinAPIEx.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 617, 393)
GUICtrlSetData(-1, "")
$Input1 = GUICtrlCreateInput("ping yandex.ru", 32, 408, 169, 21)
$Button1 = GUICtrlCreateButton("Start", 248, 408, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_read_cmd()
EndSwitch
WEnd
Func _read_cmd()
$comand = GUICtrlRead($Input1)
$sBuffer = ''
$sRead = ''
$iPID = Run(@ComSpec & ' /C ' & $comand, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
If Not $iPID Then Exit -33
While 1
$sBuffer = StdoutRead($iPID)
If @error Then ExitLoop
If $sBuffer Then
$sRead &= $sBuffer
EndIf
Sleep(2)
WEnd
$sRead = _WinAPI_OemToChar($sRead)
$sRead = StringStripCR($sRead)
$sRead = StringRegExpReplace($sRead, '((^[\n]*)|([\n]*$))', '')
$sRead = StringRegExpReplace($sRead, '[\n]{2,}', @LF)
$aRead = StringSplit($sRead, @LF)
$Lines_r = _ArrayToString($aRead, @CRLF, 1)
GUICtrlSetData($Edit1,'')
GUICtrlSetData($Edit1,$Lines_r )
EndFunc