Python 监控扫码枪输入

用python监控键盘扫描枪输入的内容

from pynput import mouse,keyboard
CODE = ""
# 处理键盘输入的数据
def on_release(key):
    global CODE
    try:
        CODE += key.char
    except Exception as e:
        try:
            if key == key.enter:
                if "http" in CODE:
                    message = CODE.replace("http;","http:")
                    print(message)
                    CODE = ""
        except Exception as e:
            CODE = ""

#监听键盘扫码枪输入
with keyboard.Listener(on_release=on_release) as listener:
    listener.join()

猜你喜欢

转载自blog.csdn.net/qq_40430818/article/details/117767326