PyHook:return keydown发射twi

2024-04-29 13:09:49 发布

您现在位置:Python中文网/ 问答频道 /正文

在下面的代码中,当我点击return时,on_key_down会被调用两次。对于其他任何键,它只被调用一次。你知道这是怎么回事吗?在

import pyHook, pythoncom, win32api

def on_key_down(e):
  if e.MessageName == 'key down':
    print 'e.Key: ', e.Key
    print 'e.Ascii: ', e.Ascii
  return True
hm = pyHook.HookManager()
hm.KeyDown = on_key_down
hm.Hookkeyboard()    
pythoncom.PumpMessages()

Tags: key代码importreturnifondefascii