Wenn ich versuche, Text von meiner RichTextBox zu Notepad ++ zu senden, sendet es nur den ersten Buchstaben des Textes. Also wenn ich in meinem Textfeld Send this to Notepad++
in Notepad ++ alles hätte, was angezeigt würde, ist S
.SendMessage zu Notepad ++ in C#
Hier ist mein Code
[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. Standardratschlag: Verwenden Sie die Benutzeroberflächenautomatisierung, um zu vermeiden, dass diese Details falsch angezeigt werden. System.Windows.Automation-Namespace. –