Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i've written a win app using c# that automatically contacts to other applications such as browsers. i want to copy something in my win app, and paste it into the browser without involving user to click or move mouse. I don't have any problem with simulating mouse cliks, but i have problem to simulating keyboard strokes. Copy (Ctrl+c) always works properly, but when i want to paste whatever in the clipboard, sometimes works properly and sometimes doesn't. Follwing is more about my problem: I want to stroke Ctrl+v using C# ,in the other words I want to paste something in the Clipboard to another application using C#.

I am using the following code:
C#
SendKeys.Send("^{v}");



I tried the following code too:
C#
SendKeys.Send("^(v)");



But the problem is that it results sometimes paste action and sometimes just stroke v key. Can anyone help with what is wrong with my application? and another question, is it the problem to access clipboard when other apps want to access it?

What I have tried:

I am using the following code:
C#
SendKeys.Send("^{v}");


I tried the following code too:
C#
SendKeys.Send("^(v)");
Posted
Updated 16-Jul-16 22:19pm

1 solution

MSDN - SendKeys.Send:
To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes.
C#
SendKeys.Send("^v");

---
SendKeys.Send Method (String) (System.Windows.Forms)[^]
 
Share this answer
 
v2
Comments
BillWoodruff 17-Jul-16 14:25pm    
+5
Kornfeld Eliyahu Peter 17-Jul-16 14:34pm    
Thank you...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900