1
0
mirror of https://github.com/aidygus/LinVAM.git synced 2024-11-23 09:18:04 +11:00
LinVAM/keyboard/__main__.py
2019-04-08 22:20:07 +08:00

13 lines
378 B
Python

# -*- coding: utf-8 -*-
import keyboard
import fileinput
import json
import sys
def print_event_json(event):
print(event.to_json(ensure_ascii=sys.stdout.encoding != 'utf-8'))
sys.stdout.flush()
keyboard.hook(print_event_json)
parse_event_json = lambda line: keyboard.KeyboardEvent(**json.loads(line))
keyboard.play(parse_event_json(line) for line in fileinput.input())