+ Reply to Thread
Results 1 to 2 of 2

Thread: Send text from form to notepad

  1. #1
    Junior Member
    Join Date
    Apr 2012

    Send text from form to notepad

    I would like to pass a text from textbox inside WPF to the notepad process.
    How can i do that ?

    I though of copying text to clipboard and then make the notepad process active but didn't work as i though it would be.
    Last edited by madlin; 11-02-2012 at 01:08 PM.

  2. #2
    Junior Member
    Join Date
    May 2012
    1- Import these DLL :
    [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
    public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
    2- SendMessage Function :
    private static void DoSendMessage(string message)
        Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
        if (notepad != null)
            IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
            SendMessage(child, 0x000C, 0, message);
    3- Example on using the function :
    DoSendMessage(textBox1.Text);  OR
    DoSendMessage("This Is Message");

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts