Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to paste clipboard contents to another app window?

How to paste clipboard contents to another app window?

Scheduled Pinned Locked Moved C#
tutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John ph
    wrote on last edited by
    #1

    trying to paste clipboard contents to another application window(word doc or ms paint) using the folowing code

    if (process != null && !process.HasExited && Clipboard.GetImage() != null)
    {
    Win32.SendMessage(process.MainWindowHandle, Win32.WM_PASTE, IntPtr.Zero, IntPtr.Zero);
    }

    it doesn't work. is anything wrong with the above approach? SendMessage and WM_PASTE does it work for sending the clipboard contents to another running process or it works only to Paste the contents of the Clipboard into a control any idea?

    - Regards -
       J O N


    A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers


    L L 2 Replies Last reply
    0
    • J John ph

      trying to paste clipboard contents to another application window(word doc or ms paint) using the folowing code

      if (process != null && !process.HasExited && Clipboard.GetImage() != null)
      {
      Win32.SendMessage(process.MainWindowHandle, Win32.WM_PASTE, IntPtr.Zero, IntPtr.Zero);
      }

      it doesn't work. is anything wrong with the above approach? SendMessage and WM_PASTE does it work for sending the clipboard contents to another running process or it works only to Paste the contents of the Clipboard into a control any idea?

      - Regards -
         J O N


      A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers


      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      John P Harris wrote:

      it doesn't work.
      is anything wrong with the above approach?

      Dunno, might be caused by isolation[^].

      I are Troll :suss:

      1 Reply Last reply
      0
      • J John ph

        trying to paste clipboard contents to another application window(word doc or ms paint) using the folowing code

        if (process != null && !process.HasExited && Clipboard.GetImage() != null)
        {
        Win32.SendMessage(process.MainWindowHandle, Win32.WM_PASTE, IntPtr.Zero, IntPtr.Zero);
        }

        it doesn't work. is anything wrong with the above approach? SendMessage and WM_PASTE does it work for sending the clipboard contents to another running process or it works only to Paste the contents of the Clipboard into a control any idea?

        - Regards -
           J O N


        A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers


        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        IMO the problem is the destination document isn't the main window of the target app; in Word you would CTRL/V in the document pane, not just anywhere inside the whole window. Suggestion: for simple apps it could work; for MS Office, I'm afraid the official way (through Primary Interop Assembly is what you need. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups