Wherever I looked online, the example code I saw to send WM_COPYDATA messages had a dependency on win32gui (not part of Python's standard library).
My project runs Python embedded in a C++ project, though, and so I want to have as few dependencies as possible.
The code below
Supports 32-bit and 64-bit Python
Uses only standard libraries (in Python 2.5+), not win32gui
This code is in Python 2; the same approach can be used in Python 3 with minor changes like making the parameter a bytes object instead of a str object.