Jump to content
Sign in to follow this  
hiimjoey11

Live ping in GUI

Recommended Posts

hiimjoey11

I found this code from a few months ago, and it is perfect for what I need except for one thing.  If you do a command like "ping" it refreshes after every line.  Is it possible to make it show every ping?

So instead of it showing:

"Reply from ....."

*screen clear*

"Reply from ....."

*screen clear*

"Reply from ....."

*screen clear*

"Done"

I want it to show:

"Reply from ....."

"Reply from ....."

"Reply from ....."

"Reply from ....."

"Done"

#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", 400, 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
iamtheky

#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", 400, 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 ###

$line = ""

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(50)
            While 1
                $line &= StdoutRead($foo)
                If @error Then ExitLoop
                If Not $line = "" Then GUICtrlSetData($Edit1,$line)
                _GUICtrlEdit_LineScroll($Edit1, 0, _GUICtrlEdit_GetLineCount($Edit1))
                sleep(50)
            WEnd
            GUICtrlSetData($input1,"")

    EndSwitch
WEnd


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
hiimjoey11
#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", 400, 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 ###

$line = ""

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(50)
            While 1
                $line &= StdoutRead($foo)
                If @error Then ExitLoop
                If Not $line = "" Then GUICtrlSetData($Edit1,$line)
                _GUICtrlEdit_LineScroll($Edit1, 0, _GUICtrlEdit_GetLineCount($Edit1))
                sleep(50)
            WEnd
            GUICtrlSetData($input1,"")

    EndSwitch
WEnd

 

that was perfect thanks!

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  

×