I am using pykeylogger and want to extend it a little bit by adding information about current keyboard layout selected (right now you know from log what buttons are pressed assuming US qwerty).
For windows system it is looks like:
def get_locale(self):
if os.name == 'nt':
w = user32.GetForegroundWindow()
tid = user32.GetWindowThreadProcessId(w, 0)
return hex(user32.GetKeyboardLayout(tid))
to get hex code of layout (like 0x409409) that is fine for me as I basically want to distinguish one layout from another.
I would appreciate if you give me a solution for posix (for example ubuntu) system.
setxkbmap -print
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+gb+gr(simple):2+inet(evdev)+terminate(ctrl_alt_bksp)" };
xkb_geometry { include "pc(pc105)" };
};
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_symbols { include "pc+gb+ gr (simple):2+inet(evdev)+terminate(ctrl_alt_bksp)" };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With