1
I need to make a program that, when the user presses a button, the program opens the notebook and insert a message previously programmed by me in the code. How could I make the program part insert the text of the message into the Notepad?
1
I need to make a program that, when the user presses a button, the program opens the notebook and insert a message previously programmed by me in the code. How could I make the program part insert the text of the message into the Notepad?
3
The following code opens the Notepad and inserts a text inside:
[DllImport("user32.dll")]
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);
static void AbrirBlocoDeNotasComTexto(string texto)
{
ProcessStartInfo startInfo = new ProcessStartInfo("notepad");
startInfo.UseShellExecute = false;
Process notepad = Process.Start(startInfo);
notepad.WaitForInputIdle();
IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), null, null);
SendMessage(child, 0x000c, 0, texto);
}
Browser other questions tagged c# windows
You are not signed in. Login or sign up in order to post.
So put what you’ve done and what problem you’re facing.
– Maniero