Direct work with the Clipboard can be done as shown in this example:
http://www.geekpedia.com/t
Main Topics
Browse All TopicsI want that the sendkeys code perform a CTRL + C. I tried two things(See code) does anybody know how to do this? Or is there a standard code in C# to do the copy to clipboard function.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Direct work with the Clipboard can be done as shown in this example:
http://www.geekpedia.com/t
So, is test2 your own application or a third party? If it is your own then it would be better to provide communication between the two applications. If your application is in control of executing test2, then this also gives you the edge. If there is a chance that the user is able to open and close test2 whenever they want, then you may want to use API to find the application, then the text control, and then extract the text that way.
If you put focus onto the test2 application and using SendKeys to send the Ctrl+C, this should work, so perhaps there is a timing thing, as the test2 application must have complete focus (that includes the control with the text selected).
Actually, scrap all this. The problem is with the Clipboard.GetText() - it does not retrieve the text from a global clipboard, only the local. If you do a Ctrl+V after the Ctrl+V you will see the text has been copied. Trying to find out the best way in .NET to retrieve the information that was just copied into the clipboard...
I think you'd be better off using API to locate the window and input the text using SendMessage. Have you used API before? It is also a little more secure since you are sending a password to the RDP application.
I'm not quite understanding what your problem is with the code snippet above. Paste the code in a textbox? Set focus on a textbox - what code is not working? None of the SendKeys work? Have you tried SendWait instead of Send?
What i mean with it is this.
1. The program do the right thing, it copy's the text from the external app
2. I've to got the code inside my app, i thought doing it this way: i've a textbox inside my app, i set the focus on it. Then i paste the text, and on the textboxchange event i let it copy to a string.
3. After this i kill the RDP app
4. Finished
I didn't used SendWait. I don't understand the reason, maybe you can post an example.
But maybe you are right and i have to use an API. Do you have a sugestion for an API ?
You would need to use multiple APIs:
FindWindow
FindWindowEx
SendMessage
Unless you are familiar with API, let's try and get the SendKeys version working.
First, I would recommend that you change the Thread.Sleep(300); line to Process.WaitForInputIdle()
Send - Sends keystrokes to the active application.
SendWait - Sends the given keys to the active application, and then waits for the messages to be processed.
Based on these descriptions, it may be advisable to use SendWait on the Ctrl+C, but the rest should be fine. I don't think it matters so much here as Ctrl+C is fast to process.
So, does the Change event not fire for the TextBox when you send ^v? Would you be able to post a set of test apps in a zip file for me to play with?
Sorry, it should be the following...
So what did you do to solve this? You shouldn't have declared my solution as an answer if it wasn't the answer. It is confusing for others that may find this question. Oh, and it is also mean to not declare what solution you found - you must have been through this yourself?
Business Accounts
Answer for Membership
by: cafejavaPosted on 2009-08-18 at 07:16:33ID: 25123451
Microsoft about the sendkey class: http://msdn.microsoft.com/ en-us/libr ary/ system .windows.f orms.sendk eys.aspx