Когда я пытаюсь отправить текст из моего RichTextBox в Notepad ++, он отправляет только первую букву текста. Поэтому, если бы у меня в текстовом поле Send this to Notepad++
в Notepad ++ все, что появилось, будет S
.SendMessage to Notepad ++ in C#
Вот мой код
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
private void button2_Click(object sender, EventArgs e)
{
Process[] notepads = Process.GetProcessesByName("notepad++");
if (notepads.Length == 0) return;
if (notepads[0] != null)
{
IntPtr child = FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Scintilla", null);
SendMessage(child, 0x000C, 0, RichTextBox1.Text);
}
}
CharSet = CharSet.Unicode. Стандартный совет: используйте автоматизацию пользовательского интерфейса, чтобы избежать неправильной информации. Пространство имен System.Windows.Automation. –