Sign in to follow this  
Followers 0
AppleHead

How to SEND data from INPUT box

6 posts in this topic

Hi, I want to be able to do what maybe is very very simple (thought not for me).

I have a gui with an input box. All I want is that whatever is typed in the INPUT box...that data can be sent (using the SEND command) to any open window...

For example...input box asks for a HOSTNAME. You input the hostname and click on the BUTTON called "ping test".

It will then open a DOS window and send the command to the DOS window: Ping <whatever u typed as hostname> [RETURN]

I have tried and tried but there is something wrong in the SEND input command. I have attached the script,

please please can someone help me, have a look at the script and see what on earth is wrong.

Thanks

Sarah

Ping Test.au3

Share this post


Link to post
Share on other sites



Hi,

#include <GUIConstantsEx.au3>

Opt("GUICoordMode", 2)
Opt('MustDeclareVars', 1)

Example1() ;Not using Send 
Example2() ;Using Send

Func Example1()
    Local $Button, $Input, $msg, $iPID
    GUICreate("Ping Test - Not using Send", 515, 310, -1, -1)
    $Button = GUICtrlCreateButton("Ping Test", 10, 50, 125)
    $Input = GuiCtrlCreateInput("your host name", -1, 10, 350, 20)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                If ProcessExists($iPID) Then ProcessClose($iPID)
                ExitLoop
            Case $Button
                $iPID = Run('cmd.exe /k ping ' & GUICtrlRead($Input))
        EndSwitch
    WEnd
EndFunc

Func Example2()
    Local $Button, $Input, $msg, $iPID
    GUICreate("Ping Test - Using Send", 515, 310, -1, -1)
    $Button = GUICtrlCreateButton("Ping Test", 10, 50, 125)
    $Input = GuiCtrlCreateInput("your host name", -1, 10, 350, 20)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                If ProcessExists($iPID) Then ProcessClose($iPID)
                ExitLoop
            Case $Button
                $iPID = Run('cmd.exe')
                Sleep(250)
                Send('ping' & GUICtrlRead($Input) & ' {ENTER}')
        EndSwitch
    WEnd
EndFunc

Cheers

Share this post


Link to post
Share on other sites

You have given me the answer I was hunting for, for days.

Thankyou and bless you.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Can you have it insert the input like in the middle of a line, like so it will type half a line of something, insert the input, than finish typing and hit enter.

ex: Input says "Mountain Dew"

Would you like a "input" or a Pepsi?

My guess as of now is I could just do:

Case $Button1
Send('Would you like a')
Send('GUICtrlRead($Input)')
Send('or a Pepsi?')
Edited by kjpolker

Share this post


Link to post
Share on other sites

Why would you use the ping of windows while you can use ping() from autoit?


Many times you need to think like hobby-bob:')

Share this post


Link to post
Share on other sites

Can you have it insert the input like in the middle of a line, like so it will type half a line of something, insert the input, than finish typing and hit enter.

ex: Input says "Mountain Dew"

Would you like a "input" or a Pepsi?

My guess as of now is I could just do:

Case $Button1
Send('Would you like a')
Send('GUICtrlRead($Input)')
Send('or a Pepsi?')

Case $Button1
Send('Would you like a ' & GUICtrlRead($Input) & ' or a Pepsi?')

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  
Followers 0