--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/q2wnlaWvLxc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
"A Windows hook is the right solution." So you mean I shouldn't use wxPython? Or is there a way to do a global Windows hook for char events in wxPython? If not how can I do this?
"You can get everything you need from the key down and up sequences." Are you sure? Because I understand that the OS has its own logic for char events. For example, if I press alt-x then it generates a key down event but not a key char event, because a character isn't emitted. Another thing is that non-US keyboards have different characters and their contained in the key char event but not the key down event.
Ram Rachum wrote:
"A Windows hook is the right solution." So you mean I shouldn't use wxPython? Or is there a way to do a global Windows hook for char events in wxPython? If not how can I do this?
I mean that pyHook will allow you to create a global Windows hook in Python. It should do what you need to do.
def SubscribeKeyChar(self, func):'''Registers the given function as the callback for this keyboard event type.Use the KeyChar property as a shortcut.B{Note}: this is currently non-functional, no WM_*CHAR messages areprocessed by the keyboard hook.@param func: Callback function@type func: callable'''
"You can get everything you need from the key down and up sequences." Are you sure? Because I understand that the OS has its own logic for char events. For example, if I press alt-x then it generates a key down event but not a key char event, because a character isn't emitted. Another thing is that non-US keyboards have different characters and their contained in the key char event but not the key down event.
It depends on what you need to do with the information. The Windows keyboard hooks -- even at the API level -- only deliver key down and key up. You can look that up in MSDN under the WH_KEYBOARD hook type.
Every key event starts with a key down. From the key down info, the input subsystem can create a char event, if the current keyboard state warrants it. A keyboard hook can't get that info, but you can certainly get the same key info that the system got.
-- Tim Roberts, ti...@probo.com Providenza & Boekelheide, Inc.
On Tue, Jul 28, 2015 at 1:55 AM, Tim Roberts <ti...@probo.com> wrote:
Ram Rachum wrote:
"A Windows hook is the right solution." So you mean I shouldn't use wxPython? Or is there a way to do a global Windows hook for char events in wxPython? If not how can I do this?
I mean that pyHook will allow you to create a global Windows hook in Python. It should do what you need to do.
PyHook doesn't support char events. From the docs:
It depends on what you need to do with the information. The Windows keyboard hooks -- even at the API level -- only deliver key down and key up. You can look that up in MSDN under the WH_KEYBOARD hook type.
One thing I want to do is get all the typed text.
Every key event starts with a key down. From the key down info, the input subsystem can create a char event, if the current keyboard state warrants it. A keyboard hook can't get that info, but you can certainly get the same key info that the system got.
I can get all the keydown events and try to recreate the char events, but then I need to reimplement logic like checking whether the alt-key was pressed, or checking the user language and translating the keypress to a character in their language, and possibly lots of other logic I'm not thinking about. A much better solution would be to get those char events directly, after the system has already applied all that logic. The question is how do I get that info.