Jump to content
Sign in to follow this  
ermilemerson

GUICtrlInput to cmd.exe

Recommended Posts

ermilemerson

Good day everyone

Can you pls. help me on how am i going to enter to command promt what i've entered on the GUICtrlInput.

$variable = GUICtrlCreateInput("", 90, 40, 70, 17)

will i use controlsend or send?

tnxtnx

Share this post


Link to post
Share on other sites
Authenticity

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

Share this post


Link to post
Share on other sites
ermilemerson

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

Share this post


Link to post
Share on other sites
KenNichols

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!

Share this post


Link to post
Share on other sites
ermilemerson

thank you very much authenticity and ken

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.