Jump to content
Sign in to follow this  
mary

redirect stdout to an Edit control

Recommended Posts

mary

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

Share this post


Link to post
Share on other sites
andygo

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.

Share this post


Link to post
Share on other sites
mary

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.