У меня в основном возникает ситуация, когда мне нужно получить расширенный текст из программы на C #, скопировать его в буфер обмена и вставить его в другое приложение с помощью pinvoke.Я знаю, как получить Handle
текстового поля, в которое оно должно быть вставлено, но WM_PASTE
, похоже, не выполняет то, что я хочу.Я потратил некоторое время на поиск в интернете, и у меня возникли большие проблемы с тем, чтобы найти много информации о том, как это сделать.
Может кто-нибудь помочь?У меня в основном есть ручка, в которую я должен вставить IntPtr
.Мне нужно получить расширенный текст из System.Windows.Forms.RichTextBox
в буфер обмена и отправить его в текстовое поле другой программы.
Это подпись pinvoke, которую я использую для отправки сообщения.
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// <br />
/// To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.
/// </summary>
/// <param name="hWnd">
/// Handle to the window whose window procedure will receive the message.
/// If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
/// </param>
/// <param name="Msg">
/// [in] Specifies the message to be sent.
/// </param>
/// <param name="wParam">
/// [in] Specifies additional message-specific information.
/// </param>
/// <param name="lParam">
/// [in] Specifies additional message-specific information.
/// </param>
/// <returns>
/// The return value specifies the result of the message processing; it depends on the message sent.
/// </returns>
[DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto, SetLastError = false)]
internal static extern IntPtr SendMessageByString(IntPtr hWnd, uint Msg, IntPtr wParam, StringBuilder lParam);
internal const int WM_SETTEXT = 0x000C;
Я вызываю SendMessageByString для дескриптора принимающего окна чата, но кажется, что он принимает только простой текст.Мне нужно перенести мой богатый текст в буфер обмена, а затем в окно чата.