Interpret \n as Enter (will need to adjust for Winshit)

This commit is contained in:
Kevin F 2023-01-21 21:27:59 -06:00
parent 608d780db1
commit 718bba4702

View File

@ -31,7 +31,7 @@ func clientConnected(w http.ResponseWriter, r *http.Request) {
} }
c.WriteMessage(websocket.TextMessage, []byte("authenticated")) c.WriteMessage(websocket.TextMessage, []byte("authenticated"))
var parts []string
for { for {
time.Sleep(25 * time.Millisecond) time.Sleep(25 * time.Millisecond)
_, message, err := c.ReadMessage() _, message, err := c.ReadMessage()
@ -44,10 +44,18 @@ func clientConnected(w http.ResponseWriter, r *http.Request) {
if message_string == "" { if message_string == "" {
message_string = "\n" message_string = "\n"
} }
err = keyboard.Type(message_string)
parts = strings.Split(message_string, "\n")
for _, part := range parts {
err = keyboard.Type(part)
if err != nil { if err != nil {
log.Println("type:", err) log.Println("type:", err)
} }
if len(parts) > 1 {
keyboard.Enter()
}
}
} }
} }