Jump to content

Command Prompt GUI

Recommended Posts


I am Trying to create a Gui in Autoit that will act and look like a CMD window. my current code works for simple commands such as ipconfig and will return the value into an edit box. But on more interactive commands such as ping and netstat. it will hang and wait for the command to finish its search before continuing. What im trying to do is have it show live data of what would be on the cmd window at all times. here is my code.


#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiScrollBars.au3>
#include <GuiEdit.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 662, 365, 290, 246)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 657, 337, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$WS_VSCROLL))
GUICtrlSetFont($Edit1, 8, 800, 0, "Times New Roman")
GUICtrlSetColor($Edit1, 0xFF0000)
GUICtrlSetBkColor($Edit1, 0x000000)
$Input1 = GUICtrlCreateInput("", 0, 336, 657, 21)
GuiCtrlSetState(-1, 512)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $Input1
            $data = GUICtrlRead($input1)
            $previous = GUICtrlRead($Edit1)
            $foo = Run(@ComSpec & " /c " & $data,@SystemDir,@SW_HIDE,$STDOUT_CHILD)
            While 1
                $line = StdoutRead($foo)
                If @error Then ExitLoop
                If Not $line = "" Then GUICtrlSetData($Edit1,$line)
                _GUICtrlEdit_LineScroll($Edit1, 0, _GUICtrlEdit_GetLineCount($Edit1))

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

  • Recently Browsing   0 members

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