Reputation: 1105
I made a program that is an onscreen keyboard. The program has some keys like normal keyboard and a textarea in bottom side. I can click the button and corresponding letters appear in the text area.
But I want to write these letters into a notepad programmitically.
How can I do that?
Edit:
So here is my sample code. How the sendkey API should behave?
public Form1()
{
var myProcess = new Process
{
StartInfo =
{
FileName = "Notepad.exe",
WindowStyle = ProcessWindowStyle.Normal
}
};
myProcess.Start();
InitializeComponent();
}
private void BtnBClick(object sender, EventArgs e)
{
SendKeys.Send("{ENTER}");
}
private void BtnCClick(object sender, EventArgs e)
{
}
Upvotes: 0
Views: 5702
Reputation: 3610
In the past i have build a similar solution by using SendKeys:
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx
And here is a demo on how to send key stokes to different windows without having a focus on those windows:
http://www.codeproject.com/Articles/18366/Sending-Keystrokes-to-another-Application-in-C
Upvotes: 4