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

Daniel F nanotube at gmail.com
Fri Apr 1 04:40:02 CEST 2005


> It depends entirely on what the application expects.  When the keyboard
> driver sends keystrokes, the generic keyboard driver translates the key
> codes to characters, if possible.  It will send WM_KEYDOWN, then WM_CHAR
> (if an ASCII translation exists), then WM_KEYUP.  Applications can
> choose which ones they want to handle.
> 
> In your case, you are bypassing the keyboard driver stack entirely.  The
> standard edit control, which is all Notepad is, apparently looks only at
> WM_CHAR.  There is no a priori method for figuring out which one is
> required.  If you need a general solution, you send all three.  In this
> case, since you want a specific solution, you can send just WM_CHAR.

Well, i do need a general solution, I was just using notepad as a test
case... So it's definitely good for me to know about this - thanks!
But i wonder, isnt there some kind of an "upstream" event, that could
be generated and then would automatically generate and propagate all
of the keydown, char, and keyup events, so i do not have to worry
about sending all three?

also, as to roel's earlier post... could I please have some help on
how to generate a bit field in python, in order to send a well-formed
lParam to SendMessage, and thus create a well-formed WM_KEYUP/KEYDOWN
event?

Thanks,
Daniel


More information about the Python-win32 mailing list