Recreate in Python

This commit is contained in:
Marek S. Łukasiewicz 2026-02-08 18:15:47 +01:00
parent f1f3260373
commit 5b30348b98
5 changed files with 353 additions and 0 deletions

25
win_telegraph.py Normal file
View file

@ -0,0 +1,25 @@
from pynput.keyboard import Key, Controller
import serial
keyboard = Controller()
dash_key = Key.space
dot_key = Key.ctrl
with serial.Serial("COM9", baudrate=115200) as ser:
while True:
character = ser.read().decode()
if character == '0':
print("none")
keyboard.release(dash_key)
keyboard.release(dot_key)
elif character == '1':
print("dot")
keyboard.release(dash_key)
keyboard.press(dot_key)
elif character == '2':
print("dash")
keyboard.press(dash_key)
keyboard.release(dot_key)
else:
print("read", character)