[python-win32] Re: Help on using win32api.SendMessage to send
keystrokes
Roel Schroeven
rschroev_nospam_ml at fastmail.fm
Fri Apr 1 13:05:38 CEST 2005
Tim Roberts wrote:
> On Wed, 30 Mar 2005 20:46:43 -0500, Daniel F <nanotube at gmail.com> wrote:
>
>> Well... i figured it out - turns out sending the keystrokes to the top
>> window of notepad didnt work, but sending them to the Edit child
>> window of notepad did the trick.
>>
>> But this brings me to another question, although of a less urgent
>> manner. i had to send WM_CHAR messages, rather than WM_KEYDOWN/KEYUP
>> in order to get it to work. I have nothing against WM_CHAR, as long as
>> everything works, but i am just curious why i was not able to achieve
>> the same effect with the WM_KEYDOWN/KEYUP pair? any takers?
>>
> 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.
Not really: AFAIK this is not done by the keyboard driver; it is done by
the TranslateMessage function which is normally called in the message loop.
MSDN on WM_CHAR: "The WM_CHAR message is posted to the window with the
keyboard focus when a WM_KEYDOWN message is translated by the
TranslateMessage function"
> In this case, since you want a specific solution, you can send just
WM_CHAR.
Indeed.
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton
Roel Schroeven
More information about the Python-win32
mailing list