diff --git a/wrp.go b/wrp.go index 62ae13b..c7ab8ee 100644 --- a/wrp.go +++ b/wrp.go @@ -47,7 +47,7 @@ type wrpReq struct { X int64 // mouseX Y int64 // mouseY K string // keys to send - B bool // history back + F string // Fn buttons } func (w *wrpReq) parseForm(req *http.Request) { @@ -73,14 +73,7 @@ func (w *wrpReq) parseForm(req *http.Request) { w.C = 256 } w.K = req.FormValue("k") - if w.K == "\\b" { - w.K = "\b" - } else if w.K == "\\r" { - w.K = "\r" - } - if req.FormValue("hist") == "Back" { - w.B = true - } + w.F = req.FormValue("Fn") log.Printf("WrpReq from Form: %+v\n", w) } @@ -88,14 +81,21 @@ func (w wrpReq) printPage(out http.ResponseWriter) { out.Header().Set("Content-Type", "text/html") fmt.Fprintf(out, "\n", version) fmt.Fprintf(out, "\nWRP %s\n\n", w.U) - fmt.Fprintf(out, "
\n") - fmt.Fprintf(out, "", w.U) - fmt.Fprintf(out, " \n") + fmt.Fprintf(out, "\n") + fmt.Fprintf(out, "", w.U) + fmt.Fprintf(out, "\n") + fmt.Fprintf(out, "\n") fmt.Fprintf(out, "W \n", w.W) fmt.Fprintf(out, "H \n", w.H) fmt.Fprintf(out, "S \n", w.S) - fmt.Fprintf(out, "C \n", w.C) - fmt.Fprintf(out, "K \n") + fmt.Fprintf(out, "C \n", w.C) + fmt.Fprintf(out, "K \n") + fmt.Fprintf(out, "\n") + fmt.Fprintf(out, "\n") + fmt.Fprintf(out, "\n") + fmt.Fprintf(out, "\n") + fmt.Fprintf(out, "\n") + fmt.Fprintf(out, "\n") fmt.Fprintf(out, "

\n") } @@ -163,14 +163,25 @@ func (w wrpReq) capture(c string, out http.ResponseWriter) { if w.X > 0 && w.Y > 0 { log.Printf("%s Mouse Click %d,%d\n", c, w.X, w.Y) - chromedp.Run(ctx, - chromedp.MouseClickXY(int64(float64(w.X)/w.S), int64(float64(w.Y)/w.S)), - ) - } else if w.B { - log.Printf("%s History Back\n", c) - chromedp.Run(ctx, - chromedp.NavigateBack(), - ) + err = chromedp.Run(ctx, chromedp.MouseClickXY(int64(float64(w.X)/w.S), int64(float64(w.Y)/w.S))) + } else if len(w.F) > 0 { + log.Printf("%s Button %v\n", c, w.F) + switch w.F { + case "Bk": + err = chromedp.Run(ctx, chromedp.NavigateBack()) + case "Bs": + err = chromedp.Run(ctx, chromedp.KeyEvent("\b")) + case "Rt": + err = chromedp.Run(ctx, chromedp.KeyEvent("\r")) + case "<": + err = chromedp.Run(ctx, chromedp.KeyEvent("\u0302")) + case "^": + err = chromedp.Run(ctx, chromedp.KeyEvent("\u0304")) + case "v": + err = chromedp.Run(ctx, chromedp.KeyEvent("\u0301")) + case ">": + err = chromedp.Run(ctx, chromedp.KeyEvent("\u0303")) + } } else if len(w.K) > 0 { log.Printf("%s Sending Keys: %#v\n", c, w.K) err = chromedp.Run(ctx,