1
0
mirror of https://github.com/aidygus/LinVAM.git synced 2024-11-15 05:38:06 +11:00
LinVAM/keyboard/__main__.py

13 lines
378 B
Python
Raw Normal View History

2019-04-09 00:20:07 +10:00
# -*- 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())