From 718bba47029bc28981aeaaaac63ccf3df2d324c2 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Sat, 21 Jan 2023 21:27:59 -0600 Subject: [PATCH] Interpret \n as Enter (will need to adjust for Winshit) --- Streaming.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Streaming.md b/Streaming.md index 80e3647..bc9e340 100644 --- a/Streaming.md +++ b/Streaming.md @@ -31,7 +31,7 @@ func clientConnected(w http.ResponseWriter, r *http.Request) { } c.WriteMessage(websocket.TextMessage, []byte("authenticated")) - + var parts []string for { time.Sleep(25 * time.Millisecond) _, message, err := c.ReadMessage() @@ -44,9 +44,17 @@ func clientConnected(w http.ResponseWriter, r *http.Request) { if message_string == "" { message_string = "\n" } - err = keyboard.Type(message_string) - if err != nil { - log.Println("type:", err) + + parts = strings.Split(message_string, "\n") + + for _, part := range parts { + err = keyboard.Type(part) + if err != nil { + log.Println("type:", err) + } + if len(parts) > 1 { + keyboard.Enter() + } } } }