Can I send a WM_COPY message that copies text somewhere other than the clipboard?

This is the definition of the method:

[DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int msg, IntPtr lparam, IntPtr wparam); 

This is the call to SendMessage:

  //WM_COPY = 0x0301 SendMessage(handle, WM_COPY, IntPtr.Zero, IntPtr.Zero); 

This is how I retrieve the data:

 string text = System.Windows.Forms.Clipboard.GetText(); 

I would like to do the same, except that I do not want the data to be copied to the clipboard. Is it possible to copy data to another part of the memory? If so, how?

0
c # winapi sendmessage
source share
2 answers

Not. You cannot control what another application will do when it receives a message. You get any task window for this message and nothing more (if you do not control the goal too, than you can handle it yourself).

WM_COPY is just a message (it is also standard and it makes sense to process it in a special way) - some windows will process it, and some will not. As defined in MSDN, WM_COPY will save text for editing control.

The application sends a WM_COPY message to the edit control or combo box to copy the current selection to the clipboard in CF_TEXT format.

If you implement your own application that processes WM_COPY, you can copy the data where you want, also if the subclass’s editing controls will go a long way towards maintaining the default behavior ...

+3
source share

Instead, you can write it to a file if the clipboard is not a parameter.

0
source share

All Articles