Reputation: 7768
I am pretty new to C# and programming in general. I am wondering if there is a way to implement the following feature:
textbox
(named tb1
) and button
(named bt1
).bt1
, my cursor will change to "selector"bt1
WindowsXP/Windows Vista/7
PS - I know how to get text from the clipboard and how to set text to the clipboard, what I need is the way to capture ANY text AFTER I press the button. For example- I have 10 textboxes; each textbox has a button.
The process would be:
button1 click -> select text in another application -> which is auto-pasted to textbox1
button2 click -> select text in another application -> which is auto-pasted to textbox2
button3 click -> select text in another application -> which is auto-pasted to textbox3
etc.
Upvotes: 5
Views: 4090
Reputation: 57149
You don't specify whether the user can click Ctrl-C in step (4) when inside that other application. If so, the selected text can indeed appear in your application: all you need to do is reading the Clipboard object, as in Clipboard.GetText()
.
A good introduction with some how-to's can be found here at CodeProject.
In the case where step (4) in your question should auto-copy the selected text to the clipboard from a foreign application, consider using an automation-tool like AutoIt or the White Framework instead (more options in this question on automation: What's a good, if any, .NET Windows automation library?).
Upvotes: 3