Python 3.5 HookManager SystemError: PyEval_EvalFrameEx
Question: I'm new here and I hope not to do any mistakes!

I'm trying to make this simple code work, I tested it on Python 3.4 32 bit and
it worked but I need to use it on Python 3.5.0 64 bit but I get this error
that I don't know how to fix.

    
    
    import pythoncom, pyHook
    
    def OnKeyboardEvent(event):
        key=chr(event.Ascii)
        print(key)
    
    hm = pyHook.HookManager()
    hm.KeyDown = OnKeyboardEvent
    hm.HookKeyboard()
    pythoncom.PumpMessages()
    

I get the pressed key printed on the screen and then I get this error:

    
    
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
    File "C:\Python 3.5\lib\site-packages\pyHook\HookManager.py", line 348, in KeyboardSwitch
    event = KeyboardEvent(msg, vk_code, scan_code, ascii, flags, time, hwnd, win_name)
    File "C:\Python 3.5\lib\site-packages\pyHook\HookManager.py", line 208, in __init__
    HookEvent.__init__(self, msg, time, hwnd, window_name)
    SystemError: PyEval_EvalFrameEx returned a result with an error set
    TypeError: an integer is required (got type NoneType)
    

I don't really know what to do!


Answer: Such a simple question without any answer? I think your function needs to
return an integer value.

It should look like this.

    
    
    def OnKeyboardEvent(event):
        key=chr(event.Ascii)
        print(key)
        return 0
    

I know it's been a while, but I hope it helps some one else!

Hope my english is understandable since it's not my first language!

