import ctypes

user32 = ctypes.WinDLL('user32', use_last_error=True)
curr_window = user32.GetForegroundWindow()

thread_id = user32.GetWindowThreadProcessId(curr_window, 0)

klid = user32.GetKeyboardLayout(thread_id)

#2 do potęgi 16(liczba całkowita nie hexydecymalna) - 1
lid = klid & (2**16 - 1)



lid_hex = hex(lid)
print lid_hex

# dalej http://atpad.sourceforge.net/languages-ids.txt
# lub tutaj https://msdn.microsoft.com/en-us/library/cc233982.aspx