Cmd logger

  • Wie im Titel beschrieben will ich z.B. manuell ne session CMD ausführen dann wenn ich da z.b. help oder dir eingebe will ich alles was ich da reinschreibe mitgeloggt wird ich hab auch einen script dafür gemacht nur klappt das leider nicht!

    theoretisch müsste is ja so gehen:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #include "constants.au3"

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

    $gui = GUICreate("console stuff")
    $edit = GUICtrlCreateEdit("", 10, 10, 300, 300, BitOr($WS_VSCROLL, $WS_HSCROLL,$ES_READONLY))
    GUISetState()

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

    $pid = Run("cmd","", @SW_SHOW)

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

    While 1
    $lineout = StdoutRead($pid)
    GUICtrlSetData($edit, $lineout, 1)
    Wend

    [/autoit]

    Und hier einmal wies funktioniert aber jedes mal ne neue dosbox gestartet wird

    Spoiler anzeigen
    [autoit]


    #include <GUIConstants.au3>
    #include "constants.au3"

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

    $gui = GUICreate("console stuff")
    $edit = GUICtrlCreateEdit("", 10, 10, 300, 300, BitOr($WS_VSCROLL, $WS_HSCROLL,$ES_READONLY))
    $go = GuiCtrlCreateButton("abfragen",310,20,60)
    $cmd = GuiCtrlCreateInput(" /c dir",310,50,60,20)
    GUISetState()
    $ping = 0

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

    While 1
    $getmsg = GuiGetMsg()
    If $go = $getmsg then
    $befehl = GuiCtrlRead($cmd)
    $ping = Run(@ComSpec & $Befehl, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    EndIf
    $lineout = StdoutRead($ping)
    GUICtrlSetData($edit, $lineout, 1)
    WEnd

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


    Wäre für Tipps / lösungen dankbar =)

  • Console in AutoIt (v3.2.10.0)
    Kommando eingeben und mit Enter abschließen :)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include "constants.au3"

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

    $gui = GUICreate("console stuff")
    $edit = GUICtrlCreateEdit("", 10, 10, 300, 300, BitOr($WS_VSCROLL, $WS_HSCROLL,$ES_READONLY))
    $inp = GUICtrlCreateInput("",10,320,300,20)
    GUISetState()

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

    $pid = Run("cmd.exe",@SystemDir, @SW_HIDE, $STDOUT_CHILD+$STDIN_CHILD) ; CMD wird verteckt geöffnet

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

    While 1
    If StdoutRead($pid,0,1) Then
    $lineout = StdoutRead($pid)
    GUICtrlSetData($edit, $lineout, 1)
    EndIf
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $inp Then
    If GUICtrlRead($inp) = "exit" Then Exit
    StdinWrite($pid,GUICtrlRead($inp)&@CRLF)
    EndIf
    Wend

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

    Func OnAutoItExit()
    StdinWrite($pid,@CRLF&"exit"&@CRLF)
    ProcessWaitClose($pid,2)
    If ProcessExists($pid) Then MsgBox(0, 'AutoIt Console', "Console Schließt nicht - Force Termination")
    ProcessClose($pid)
    Exit (0)
    EndFunc

    [/autoit]

    //Edit: CMD versteckt öffnen :)

    Einmal editiert, zuletzt von progandy (13. Februar 2008 um 16:02)

  • Fettes Beispiel! :rock:

    Psst...
    Ändere mal Zeile 10 in
    $pid = Run("cmd.exe",@SystemDir, @SW_HIDE, $STDOUT_CHILD+$STDIN_CHILD)
    Viel cooler 8)

  • ich weiß war ja auch so gedacht aber nur wollte ich dass ich was IN die CMD box schreiben kann und das es dann wieder in edit ausgegeben wird und nicht von

    Input ---> Dos ---> Edit

    sondern

    Dos --> Edit

    =)
    ich shcau nochmal selbst aber wenn jmd sofort drauf kommt kann ers gerne posten.

  • hab ich nicht hinbekommen aber hier die final version von propagandy noch verbessert.

    Spoiler anzeigen
    [autoit]


    #include <Constants.au3>
    #include <GUIConstants.au3>

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

    $foo = Run("cmd.exe", "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)

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

    $gui = GUICreate("console stuff",320,350)
    $edit = GUICtrlCreateEdit("", 10, 10, 300, 300, BitOr($WS_VSCROLL, $WS_HSCROLL,$ES_READONLY))
    $input = GuiCtrlCreateInput("",10,320,300,20)

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

    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $input Then
    StdinWrite($foo,GUICtrlRead($input)&@CRLF)
    EndIf
    If StdoutRead($foo,0,1) Then
    $lineout = StdoutRead($foo)
    GUICtrlSetData($edit, $lineout, 1)
    GuiCtrlDelete($input)
    $input = GuiCtrlCreateInput("",10,320,300,20)
    GuiCtrlSetState($input,$GUI_FOCUS)
    EndIf
    Wend

    [/autoit]
  • Was ist da besser? :)
    Hier noch mal von mir:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include "constants.au3"
    Global $textLength
    $gui = GUICreate("console stuff")
    $edit = GUICtrlCreateEdit("", 10, 10, 300, 300, BitOr($WS_VSCROLL, $WS_HSCROLL,$ES_READONLY))
    $inp = GUICtrlCreateInput("",10,320,300,20)
    GUISetState()

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

    $pid = Run("cmd.exe",@SystemDir, @SW_HIDE, $STDOUT_CHILD+$STDIN_CHILD+$STDERR_CHILD) ; CMD wird verteckt geöffnet

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

    While 1
    If StdErrRead($pid,0,1) Then
    $lineout = StderrRead($pid)
    GUICtrlSendMsg($edit,$EM_SETSEL,$textLength,-1)
    $textLength += StringLen($lineout)
    GUICtrlSetData($edit, $lineout, 1)
    EndIf
    If StdoutRead($pid,0,1) Then
    $lineout = StdoutRead($pid)
    GUICtrlSendMsg($edit,$EM_SETSEL,$textLength,-1)
    $textLength += StringLen($lineout)
    GUICtrlSetData($edit, $lineout, 1)
    EndIf
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $inp Then
    $input = GUICtrlRead($inp)
    If StringLower($input) = "exit" Then
    Exit
    ElseIf StringLower($input) = "cls" Then
    GUICtrlSetData($edit,"")
    $textLength = 0
    EndIf
    StdinWrite($pid,$input&@CRLF)
    GUICtrlSetData($inp,"")
    GUICtrlSetState($inp,$GUI_FOCUS)
    EndIf
    Wend

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

    Func OnAutoItExit()
    StdinWrite($pid,@CRLF&"exit"&@CRLF)
    ProcessWaitClose($pid,2)
    If ProcessExists($pid) Then MsgBox(0, 'AutoIt Console', "Console Schließt nicht - Force Termination")
    ProcessClose($pid)
    Exit (0)
    EndFunc

    [/autoit]


    Jetzt wird immer am Ende eingefügt, cls geht und Input wird geleert.
    //edit: Jetzt ist es egal, ob CLS oder EXIT groß geschrieben werden

    //Edit: Umlaute und STRG + C gehen leider net :(

    Einmal editiert, zuletzt von progandy (13. Februar 2008 um 16:28)