1

我有 PyHook 循环

hm = pyHook.HookManager()
hm.KeyDown = Ob.on_keyboard_event
hm.HookKeyboard()
pythoncom.PumpMessages()

Ob.on_keyboard_event每次 启动都event.Ascii来自键盘。因为它在自己def keyboard(self)扫描布局时无法识别布局开关。但def keyboard_layout(self)就像on_keyboard_event只有在偶数出现后才能工作一样,所以在更改布局之前会有 1 个字符的滞后。我想制作第二个循环,def keyboard_layout(self)以便它每 0.5 秒独立检查一次布局,并在需要时进行更改。现在它发生在

def on_keyboard_event(self, event):

    a = self.keyboard_layout()

    if a == hex(0x4090409):

        win32api.LoadKeyboardLayout("00000409", 1)

    else:

        win32api.LoadKeyboardLayout("00000419", 1)
4

0 回答 0