Jump to content

GUICtrlInput to cmd.exe


Recommended Posts

Neither:

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

Dim $hGUI = GUICreate('Test', 230, 300)
Dim $Input = GUICtrlCreateInput('dir /b C:\', 10, 10, 220, 23)
Dim $Button = GUICtrlCreateButton('Run', 80, 38, 70, 23)
Dim $Output = GUICtrlCreateEdit('...', 10, 76, 220, 214)
Dim $sOutput
Dim $CmdID

GUISetState()
While 1
    Switch GUIGetMsg()
        Case $Button
            $CmdID = Run(@ComSpec & ' /c ' & GUICtrlRead($Input), '', @SW_HIDE, BitOR($STDIN_CHILD, $STDOUT_CHILD))
            $sOutput = ''
            While 1
                $sOutput &= StdoutRead($CmdID)
                If @error Then ExitLoop
            Wend
            GUICtrlSetData($Output, $sOutput)
            
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

GUIDelete()
Exit
Link to comment
Share on other sites

uhm, may i have it this way?

a GUICtrlInput box will appear then I will enter name of a computer (e.g. emerson)

then a variable will store what i have entered ( e.g. $variable = GUICtrlCreateInput("", 90, 40, 70, 17) )

then i will load the data stored in the $variable like this

Run("cmd.exe")

WinWaitActive("C:\WINDOWS\system32\cmd.exe")

send("ping""{"& $variable &"}")

this script isn't working.

can you help me figure out what to do.

i want the output to be like this

C:\ping emerson

thank you very much

Link to comment
Share on other sites

I added to Authenticity's code.

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <WindowsConstants.au3>


Dim $hGUI = GUICreate('Test', 310, 300)
Dim $Input = _GUICtrlIpAddress_Create($hGUI, 65, 10, 180, 23)
_GUICtrlIpAddress_Set($Input, "0.0.0.0")
Dim $Button = GUICtrlCreateButton('Run', 120, 38, 70, 23)
Dim $Output = GUICtrlCreateEdit('...', 10, 76, 290, 214)
Dim $sOutput
Dim $CmdID

GUISetState()
While 1
    Switch GUIGetMsg()
        Case $Button
    $CmdID = Run(@ComSpec & ' /c ping ' & _GUICtrlIpAddress_Get($Input), '', @SW_HIDE, BitOr($STDIN_CHILD, $STDOUT_CHILD))
            $sOutput = ''
            While 1
                $sOutput &= StdoutRead($CmdID)
                If @error Then ExitLoop
            Wend
            GUICtrlSetData($Output, $sOutput)

        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

GUIDelete()
Exit
[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!
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
 Share

  • Recently Browsing   0 members

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