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

Daniel F nanotube at gmail.com
Fri Apr 1 23:19:56 CEST 2005


Thank you all for your suggestions! Using PostMessage with
WM_KEYDOWN/KEYUP, and creating the lparam bitfield like that, does the
trick quite well. Really appreciate your help! :)

On Apr 1, 2005 12:59 PM, Tim Roberts <timr at probo.com> wrote:
> On Thu, 31 Mar 2005 21:40:02 -0500, Daniel F <nanotube at gmail.com> wrote:
> 
> >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?
> >
> >
> 
> You might investigate MapVirtualKey, keybd_event, and SendInput.  I have
> no clue whether these are exposed in the Python Win32 extensions.
> Overall, I would guess the three-message parlay is the lowest-impact method.
> 
> >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?
> >
> 
> Python supports C expressions; you just build it by hand:
> 
>     bits = 0x8000000 | 0x00030000 | vkKey
> 
> Or, if you prefer the bit numbers explicitly:
> 
>     bits = (2 << 30) | (3 << 16) | vkKey
> 
> --
> - Tim Roberts, timr at probo.com
>   Providenza & Boekelheide, Inc.
> 
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>


More information about the Python-win32 mailing list