简体   繁体   English

如何在C#中以编程方式写入记事本

[英]How to write into a notepad programmatically in c#

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? sendkey API应该如何表现?

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)
{
}

In the past i have build a similar solution by using SendKeys: 在过去,我已经使用SendKeys建立了一个类似的解决方案:

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx 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 http://www.codeproject.com/Articles/18366/Sending-Keystrokes-to-another-Application-in-C

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM