Dynamic copy/paste using DDE with Python on Windows

Richie Hindle richie at entrian.com
Wed Oct 16 08:23:55 EDT 2002


Peter Hansen <peter at engcorp.com> wrote:
> Also, as far as I recall DDE was always broken in a number of,
> uh, "interesting" ways and probably not worth your time trying
> to get it working.  Maybe someone else will point out that
> I'm wrong about that...

I'll do the opposite, and point out that you're exactly right about
that.  Its worst offense (that I know of) is using broadcast messages
via SendMessage(HWND_BROADCAST...) in order to find DDE server
processes.  If there's an unresponsive window in any process (examples
that I've seen have included a crashed screensaver, a GUI process
stopped in a debugger, and a GUI process that had called into a JVM to
bring up a Java-driven UI) then any DDE client will hang.  As an
example, if I do this:

>>> from win32gui import CreateWindow
>>> w = CreateWindow("EDIT", "Test", 0, 0, 0, 10, 10, 0, 0, 0, None)

and then go Start / Programs / New Office Document / Blank Document,
nothing happens.  I exit the Python process and my new document
immediately appears.  The reason is that the New Office Document
program uses DDE to find an existing Word instance, and DDE (outside
of the control of New Office Document) calls
SendMessage(HWND_BROADCAST...).  The message is sent to my "Test"
window, which has no message loop and therefore can't process the
message, and the whole thing locks up indefinitely.  This has been the
cause of many an unreproducible bug report!

-- 
Richie Hindle
richie at entrian.com



More information about the Python-list mailing list