Jump to content
Sign in to follow this  
MIchaelfjsmith2

Command Prompt GUI

Recommended Posts

MIchaelfjsmith2

Team,

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.

Thanks,

#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)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd

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  

×