Jump to content

redirect stdout to an Edit control


Recommended Posts

Hi !

I'm trying to display the stdout of an external console application in an Edit control.

The pb is that the stdout is not like cmd.exe console (characters not well formated, and lot of lines is displayed)

any suggestion ?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 443, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 88, 80, 409, 273)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Button1", 504, 32, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $foo = Run(@ComSpec & " /c ipconfig /all", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)




Local $line=""
While 1
    $line &= StdoutRead($foo)
    If @error Then ExitLoop
    ;MsgBox(0, "STDOUT read:", $line)
    GUICtrlSetData($Edit1,  $line)
Wend

While 1
    $line &= StderrRead($foo)
    If @error Then ExitLoop
   ; MsgBox(0, "STDERR read:", $line)

   GUICtrlSetData($Edit1,  $line)
Wend


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Link to comment
Share on other sites

hi,

in my case i did it like this:

RunWait(@ComSpec & " /c " & "ipconfig /all |findstr /i /C:""Physical Adress"" >>" & FileGetShortName(@AppDataDir) & "\chk.ag", "", @SW_HIDE)

i fill a temp-file with (for example) just the physical adresses.

then i read the file into a variable and do some strin-operations to sort it like i want...

maybe this helps you.

Link to comment
Share on other sites

it is an idea but it is not a solution.

in fact, the external console process (antivirus csscan.exe of mcafee), has a stream output like a progress list of scanned files. My edit control must display the same effect

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...