[python-win32] Re: Help on using win32api.SendMessage to sendkeystrokes

Mark Hammond mhammond at skippinet.com.au
Sun Apr 3 05:21:20 CEST 2005

> as i understand it, then...  PostMessage expects exactly 32bits... and
> my guess is that since python has no unsigned ints, a 32bit value
> needs more than 32bits, so python makes it a long, and then
> postmessage complains about longs because it expects an int-sized
> value.

PostMessage wants a Python integer object (or a long that could fit in an
int).  In practice, that means sending a negative integer when you want the
MSB set.

Sadly (IMO), in Python 2.4, all these bitwise operations have become more
"pythonic" rather than like C.  Thus, in 2.3 and earlier:

>>> 1<<31

but 2.4+:

>>> 1<<31

> Would that be a bug in python's implementation of PostMessage,
> or am i missing something?

Many of the pywin32 functions work like this, and will not accept the new
long value.  I beleive that can be fixed fairly easily - but changing the
return values from these functions would open a can of worms.  I'm not sure
of a clean solution.


More information about the Python-win32 mailing list