开发者

Want to send the text to the Active Window

开发者_运维知识库

Want to send the text from my current vb application to the Active Window and that text should be displayed in the text area of the active window can anyone help me?


You need to send WM_SETTEXT message to the text control. Like this:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern void SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);

 private const int WM_SETTEXT = 0x0C;

private void button1_Click(object sender, EventArgs e)
{
  string txt = "Hello World";
  SendMessage(richTextBox1.Handle, WM_SETTEXT, 0, txt);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜