FindWindowEX で見つかったプロセスに SendMessage を使用すると、正常に動作し、特定のアプリケーションにテキストを送信できます。
GetForegroundWindow を使用してウィンドウを見つけ、テキストを送信しようとすると、機能しません。テキストをウィンドウに送信するのではなく、タイトルテキストを設定しています。
それを解決するのを手伝ってもらえますか、以下のコードを見てください
//using FindWindowEX
Process[] notepads = Process.GetProcessesByName("notepad");
FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Edit", null);
SendMessage(child, 0x000C, 0, "testing");
//Using GetForegroundwidow
IntPtr child = GetForegroundWindow();(0), "Edit", null);
SendMessage(child, 0x000C, 0, "testing");