How to paste clipboard contents to another app window?
-
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
andWM_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
-
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
andWM_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
-
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
andWM_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
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.