none
Is it possible to paste data from clipboard to another application without using sendkeys? RRS feed

  • Question

  • I can copy data to clipboard sucessfully with:
     DataObject data = new DataObject();
     data.SetData(DataFormats.Text, rtb_Output.SelectedText);
    But I cant paste into notepad without sendkeys "^v". Is there a way to paste another app without sendkeys? Thanks in advance.
    Tuesday, February 27, 2018 1:41 PM

All replies

  • You can send WM_PASTE

    public const int WM_PASTE = 0x0302;
    (to the Edit control in Notepad for example)


    Tuesday, February 27, 2018 1:52 PM
  • Perhaps you should ask a different question. You can get the edit control in Notepad and put text into it directly. If however you really want to do this for a different application that has a different control (not an edit control) then it might not work.


    Sam Hobbs
    SimpleSamples.Info

    Tuesday, February 27, 2018 11:39 PM
  • Hello Denis,

    >>Is there a way to paste another app without sendkeys?

    Try to look up Clipboard , If you want to get clipboard data, you could use Clipboard.GetText method. A simple test like below.

            private void button2_Click(object sender, EventArgs e)
            {
                DataObject data = new DataObject();
                data.SetData(DataFormats.Text, "ddddddddddd");
                Clipboard.SetDataObject(data);
    
    
                richTextBox1.Text= Clipboard.GetText();
    
            }

    Best regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 28, 2018 8:22 AM
    Moderator
  • Denis Valjean wants to do that in Notepad.


    Sam Hobbs
    SimpleSamples.Info

    Wednesday, February 28, 2018 3:33 PM
  • Hi Denis,

    I'm little confused about what you want. What do you mean by "can't paste into notepad without sendkeys '^v' "? You cannot paste rtb_Output.SelectedText to notepad? Does "^v" stands for "ctrl+v"? Do you mean paste automatically to notepad by "without sendkeys"?

    Best Regards,

    Charles


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 6, 2018 7:25 AM