I have PyHook loop
hm = pyHook.HookManager()
hm.KeyDown = Ob.on_keyboard_event
hm.HookKeyboard()
pythoncom.PumpMessages()
that initiates Ob.on_keyboard_event
every time event.Ascii
comes around from the keyboard. Because it doesn't recognize layout switch on its own def keyboard(self)
scans for layout. But def keyboard_layout(self)
just like on_keyboard_event
works only after an even has come so there is a lag in 1 character before the layout is changed.
I want to make a second loop out of def keyboard_layout(self)
so it would independently check layout every 0.5s and change it if needed. Right now it happens as
def on_keyboard_event(self, event):
a = self.keyboard_layout()
if a == hex(0x4090409):
win32api.LoadKeyboardLayout("00000409", 1)
else:
win32api.LoadKeyboardLayout("00000419", 1)