简体   繁体   中英

Recording keystrokes with pyHook

I've been trying to get this to work for some time now (to get the keyid to print in text, A="A", not A=125.)

Here is my code, it either prints "None" and sometimes it prints the wrong type, or even just the keyid again. (With different IDToName arguments)

import pyHook
from pyHook import HookManager
from pyHook.HookManager import HookConstants
import time
import pythoncom



def OnKeyboardEvent(event):
    print HookConstants.IDToName(event.Ascii)

hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()

while True:
    pythoncom.PumpMessages()

why not just use event.Key ? xx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM