Wait, spoke a bit too soon. I noticed that you (Tim) apparently missed a zero in your first method of building the bits (8 with 6 zeros instead of 7), which generates only a 28bit number, not 32bits. (which i blindly copy pasted at first...). when i try to make an actual 32bit value, and then send it to the PostMessage function, i get the following exception:
win32api.PostMessage(self.subHwnd, win32con.WM_KEYDOWN, virtualKeyCode, keyDownBits) OverflowError: long int too large to convert to int 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. Would that be a bug in python's implementation of PostMessage, or am i missing something? btw, postmessage(keydown) works just as well with a 31-bit value... so i guess i have no problem with this, just asking out of curiosity. Thanks, Daniel On Apr 1, 2005 4:19 PM, Daniel F <[EMAIL PROTECTED]> wrote: > 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 <[EMAIL PROTECTED]> wrote: > > On Thu, 31 Mar 2005 21:40:02 -0500, Daniel F <[EMAIL PROTECTED]> 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, [EMAIL PROTECTED] > > Providenza & Boekelheide, Inc. > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32