msdos fenster anzeigen in gui

  • Hallo,

    ich würde mir gerne die msdos Ausgabe von z.B. ping in einer gui anzeigen lassen, bekomme aber alles in einer Zeile und nicht schön untereinander.
    Wie kann ich die einzelne Zeilen mir anzeigen lassen ?


    [autoit]

    #include <ButtonConstants.au3>#include <ComboConstants.au3>#include <GUIConstantsEx.au3>#include <WindowsConstants.au3>#include <GUIConstants.au3>#include <file.au3>#include <Date.au3>#include <array.au3>#include <Process.au3>#include <ProgressConstants.au3>#include <StaticConstants.au3>#include <UpdownConstants.au3>#include <EditConstants.au3>#include <ListboxConstants.au3>#include <ComboConstants.au3>#include <Constants.au3>#include <ButtonConstants.au3>#include <StaticConstants.au3>#include <GuiListView.au3>
    $Form1_1 = GUICreate("ping Status", 850, 450, 300, 160)GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")$EXIT = GUICtrlCreateButton("EXIT", 100, 368, 145, 41, $BS_PUSHLIKE)GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")$Button1 = GUICtrlCreateButton("Ping Status", 24, 25, 150, 35)GUISetState(@SW_SHOW)
    While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 $cmdreturn = "" $returncode=run(@ComSpec & " /c " & "ping 127.0.0.1",@SystemDir, @SW_HIDE, $STDERR_MERGED + $STDIN_CHILD) While 1 ; loop through the return from the command until there is no more $line = StdoutRead($returncode) If @error Then ExitLoop $cmdreturn &= $line WEnd $cmdreturn1=StringSplit($cmdreturn,@CRLF) For $i = 0 To UBound($cmdreturn1) - 1 GUICtrlCreateInput($cmdreturn1[$i] , 180, 155, 600, 60) Next GUICtrlCreateInput($cmdreturn, 180, 25, 600, 60) Case $GUI_EVENT_CLOSE Exit Case $EXIT Exit EndSwitchWEnd

    [/autoit]

    Einmal editiert, zuletzt von donpascal (3. März 2014 um 15:47)

  • [autoit]


    ; Demonstriert StdoutRead()
    #include <Constants.au3>

    [/autoit][autoit][/autoit][autoit]

    Local $foo = Run(@ComSpec & " /c ping 127.0.0.1", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $line
    While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT gelesen:", $line)
    WEnd

    [/autoit][autoit][/autoit][autoit]

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

    [/autoit][autoit][/autoit][autoit][/autoit]
  • Du solltest nicht hunderte von Input Controls übereinander erstellen.
    Controls am besten immer am Anfang erstellen und zur Laufzeit nur die Daten verändern ;)

    So z.B:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <Constants.au3>
    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $Form1_1 = GUICreate("ping Status", 850, 450, 300, 160)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $EXIT = GUICtrlCreateButton("EXIT", 100, 368, 145, 41, $BS_PUSHLIKE)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("Ping Status", 24, 25, 150, 55)
    $Edit1 = GUICtrlCreateEdit('', 180, 25, 600, 100)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button1
    $cmdreturn = ""
    $returncode = Run(@ComSpec & " /c " & "ping 127.0.0.1", @SystemDir, @SW_HIDE, $STDERR_MERGED + $STDIN_CHILD)
    While 1 ; loop through the return from the command until there is no more
    $line = StdoutRead($returncode)
    If @error Then ExitLoop
    If StringLen($line) Then
    $cmdreturn &= $line
    GUICtrlSetData($Edit1, $cmdreturn)
    EndIf
    WEnd
    Case $GUI_EVENT_CLOSE
    Exit
    Case $EXIT
    Exit
    EndSwitch
    WEnd

    [/autoit]