Hi,
I need to be able to listen for and send keyboard inputs, even when the python application isn't in focus. So far I've looked at 'keyboard' and 'pynput'. They looked promising however often I'll need to listen to and send numpad keys, and for example in the packages mentioned the code for numpad 0 is the same as the regular number 0 and so on. I need to do this as another program globally listens for these hotkeys, and it differentiates between regular buttons and the numpad, for example if you set a hotkey in that program as 0 on the numpad, it will display in the menu as "NumPad0", and sending an event for the regular number 0 will not trigger it.
Kind Regards,
Kaine
Hi,
As I mentioned in my original post I have tried pynput but it does not seem to differentiate the numpad to the regular numbers. Is there something about pynput that I'm missing?
Thanks
That doesn't seem to differentiate numpad keys, the code for numpad 0 is just the code for insert for example and won't trigger the other programs hotkeys.
So far I've managed to send out keypresses using VK codes and the win32api, it looks like I can also register global hotkeys.
Now I need a way to globally listen for VK codes, any ideas?
the code 0 is not a scan code.
In fact there are many different versions of keyboards, depending on country
a typical layout would have the following scan codes:
Output:
--- --------------- --------------- --------------- -----------
| 01| | 3B| 3C| 3D| 3E| | 3F| 40| 41| 42| | 43| 44| 57| 58| |+37|+46|+45|
--- --------------- --------------- --------------- -----------
----------------------------------------------------------- ----------- ---------------
| 29| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 0E| |*52|*47|*49| |+45|+35|+37| 4A|
|-----------------------------------------------------------| |-----------| |---------------|
| 0F| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B| 2B| |*53|*4F|*51| | 47| 48| 49| |
|-----------------------------------------------------------| ----------- |-----------| 4E|
| 3A| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 1C| | 4B| 4C| 4D| |
|-----------------------------------------------------------| --- |---------------|
| 2A| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35| 36| |*4C| | 4F| 50| 51| |
|-----------------------------------------------------------| ----------- |-----------|-1C|
| 1D|-5B| 38| 39|-38|-5C|-5D| -1D| |*4B|*50|*4D| | 52| 53| |
----------------------------------------------------------- ----------- ---------------
the keyboard will emit several codes to identify a single key, for example Enter key actually outputs the sequence FA F0 BA
here's a good writeup:
http://www.quadibloc.com/comp/scan.htm
post 84 here seems to have some code that will work.
https://stackoverflow.com/questions/1356...-in-python