Copy selected area text to clipboard

I am new to C # and programming in general. I am wondering if there is a way to implement the following function:

  • in my C # program there is textbox(with a name tb1) and button(with a name bt1).
  • When I click bt1, my cursor will change to a "selector"
  • I switch to a program where I need a value to be taken from
  • I select the text that I need to copy into my C # program
  • The selected text appears in bt1

WindowsXP / Windows Vista / 7

PS - I know how to get text from the clipboard and how to set text to the clipboard, I need a way to capture ANY text AFTER I press the button. For example, I have 10 text fields; Each text box has a button.

The process will look like this:

  • button1 click → select text in another application → which is automatically inserted into the text box1

  • button2 click → select text in another application → which is automatically inserted into the text box2

  • button3 click → select text in another application → that is automatically inserted into the text box3

and etc.

+5
source share
1 answer

You will not indicate whether the user can press Ctrl-C in step (4) when inside this other application. If so, the selected text may indeed appear in your application: all you have to do is read the Clipboard object, as in Clipboard.GetText().

A good introduction with instructions can be found here in CodeProject .


, (4) , , AutoIt " " ( : , , Windows Windows?).

+3