Jump to content

CMD output indent GUICtrlCreateEdit


rootx
 Share

Recommended Posts

I hope someone explain me how to do that... well, if you run the command netstat -a inside cmd prompt he look nice( indented ) but if you try to show the output inside the GUICtrlCreateEdit he look without indentation... how can I  fix it? Thx

$Pid = Run(@ComSpec & " /c " & "netstat -a",@ScriptDir,@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)
                
                Dim $_StderrRead='', $_StdoutRead='', $_StdReadAll=''

                While ProcessExists ( $Pid )
                    $_StderrRead = StderrRead ( $Pid )
                    If Not @error And $_StderrRead <> '' Then
                        GUICtrlSetData($Edit1, "Error: " & $_StderrRead & @Crlf ,1)
                    EndIf
                    $_StdoutRead = StdoutRead ( $Pid )
                    If Not @error And $_StdoutRead <> '' Then
                        GUICtrlSetData($Edit1, "Log: " & $_StdoutRead & @Crlf ,1)
                    EndIf
                Wend

 

Link to comment
Share on other sites

rootx,

Here's something I did a while ago up...hope it helps...

; example of using stdout with network commands

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <StaticConstants.au3>

Local $Gui010  = GUICreate("Network Properties", 800, 600)
Local $Button1 = GUICtrlCreateButton("IPCONFIG",10,  10, 75, 25)
Local $Button2 = GUICtrlCreateButton("NETSTAT", 90, 10, 75, 25)
Local $clear   = GUICtrlCreateButton("Clear Display", 700, 10, 90, 25)
                 GUICtrlSetBkColor($clear,0xaaaaaa)
                 GUICtrlSetFont($clear,10,800,default,'times new roman')
                 GUICtrlCreateLabel("PARM = ",175,15,50,25)
Local $parm    = GUICtrlCreateEdit('',225,10,75,25,$ss_sunken)
                 GUICtrlSetFont($parm,12,800)
                 GUICtrlSetState($parm,$gui_focus)
Local $Edit010 = GUICtrlCreateEdit("", 10,40,780,550, $ES_AUTOVSCROLL + $WS_VSCROLL + $ws_hscroll + $es_readonly)
                 GUICtrlSetFont(-1,8.5,800,default,'courier new')

GUISetState(@SW_SHOW)

Local $rslt,$out

While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                _do_exit_stuff()
            Case $msg = $Button1
                $rslt = Run(@ComSpec & " /c ipconfig " & GUICtrlRead($parm), @SystemDir, @SW_HIDE, $STDERR_MERGED + $STDOUT_CHILD)
                While 1
                    $out = StdoutRead($rslt)
                    If @error then exitloop
                    GUICtrlSetData($edit010,$out & @lf,1)
                WEnd
            Case $msg = $Button2
                $rslt = Run(@ComSpec & " /c netstat " & GUICtrlRead($parm), @SystemDir, @SW_HIDE, $STDERR_MERGED + $STDOUT_CHILD)
                While 1
                    $out = StdoutRead($rslt)
                    If @error then exitloop
                    GUICtrlSetData($edit010,$out & @lf,1)
                WEnd
            Case $msg = $clear
                GUICtrlSetData($edit010,"")
        EndSelect
WEnd

func _do_exit_stuff()

    ; whatever you want here

    Exit

endfunc

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...