Jump to content

Using Control Send w/ Button and read text from message


Justen
 Share

Recommended Posts

Hello, I am making an auto typer however I need some help with a few things. I am wanting to use control send so that the application can remain minimized leaving the option available to do other things while the application runs. First, I am unsure, how could I go about allowing the person using the appication to select which window or application the script will use control send on?

Secondly, I am wanting to have it send the text to the window whenever the user runs it. So far I have only created my GUI with Koda and I have gotten somewhat stumped as what to do next. Would it be possible that someone could explain to me how to obtain the text from the message box and how to select which process or window to control send the string to?

For example, I am using

$Message = GUICtrlCreateInput("Message", 8, 136, 377, 21)

Where I can input the string to use control send

And a simple button to start the application and send it. Im very confused about this entirely. I have used control send just in a script but I would like to create an actual executable application that could be used.

Thank you!

Link to comment
Share on other sites

Hello, I am making an auto typer however I need some help with a few things. I am wanting to use control send so that the application can remain minimized leaving the option available to do other things while the application runs. First, I am unsure, how could I go about allowing the person using the appication to select which window or application the script will use control send on?

Secondly, I am wanting to have it send the text to the window whenever the user runs it. So far I have only created my GUI with Koda and I have gotten somewhat stumped as what to do next. Would it be possible that someone could explain to me how to obtain the text from the message box and how to select which process or window to control send the string to?

For example, I am using

$Message = GUICtrlCreateInput("Message", 8, 136, 377, 21)

Where I can input the string to use control send

And a simple button to start the application and send it. Im very confused about this entirely. I have used control send just in a script but I would like to create an actual executable application that could be used.

Thank you!

This may give you some ideas.

It is the GUICtrlCreateInput() help file example modified.

Enter text into input box.

Press OK button.

The text is placed where the next left mouse button clicks on. Provided it is a place that accepts text.

#include <GUIConstantsEx.au3>
#include <Misc.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $file, $btn, $msg

    GUICreate(" My GUI input ", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
    $file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                Do
                    Sleep(10)
                Until _IsPressed("01")
                Send(GUICtrlRead($file) & "  This is a line of text in the notepad window")
        EndSelect
    WEnd
EndFunc   ;==>Example



;
Link to comment
Share on other sites

This may give you some ideas.

It is the GUICtrlCreateInput() help file example modified.

Enter text into input box.

Press OK button.

The text is placed where the next left mouse button clicks on. Provided it is a place that accepts text.

#include <GUIConstantsEx.au3>
#include <Misc.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $file, $btn, $msg

    GUICreate(" My GUI input ", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
    $file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                Do
                    Sleep(10)
                Until _IsPressed("01")
                Send(GUICtrlRead($file) & "  This is a line of text in the notepad window")
        EndSelect
    WEnd
EndFunc   ;==>Example



;
Thanks for the help! This helped me alot. I was able to fix it to almost everything I need however I need to use controlsend and i am somewhat unsure how to modify

Send(GUICtrlRead($file) & "")

To use control send with a variable.

I thought that by using

ControlSend("Title" ,GUICtrlRead($file) & "")

However the arguments aren't correct?

Thanks again for the help!

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...