From c07f24d8fdcb2f8c0a83a7faf0431d5d649c3f6c Mon Sep 17 00:00:00 2001 From: "samuel.miranda" Date: Tue, 5 Oct 2021 17:35:25 -0300 Subject: [PATCH] Teste --- api/ocr/cli.go | 197 ++++++++++++++++++++++++++++++++++++++++++++++ api/wingui/cli.go | 111 ++++++++++++++++++++++++++ 2 files changed, 308 insertions(+) create mode 100644 api/ocr/cli.go diff --git a/api/ocr/cli.go b/api/ocr/cli.go new file mode 100644 index 0000000..cf989d8 --- /dev/null +++ b/api/ocr/cli.go @@ -0,0 +1,197 @@ +package wingui + +import ( + "fmt" + + "go.digitalcircle.com.br/open/replaycli-go/api" +) + +type Cli struct { + cli *api.Cli +} + +func (c *Cli) HttpCli() *api.Cli { + return c.cli +} + +func (c *Cli) Ocr_screen(l string) (map[string]interface{}, error) { + d := 0 + ret := make(map[string]interface{}) + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/ocr/screen?l=%s&d=%d", l, d), &ret) + return ret, err +} + +func (c *Cli) ClipRead() (string, error) { + ret := "" + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/clip/read"), &ret) + return ret, err +} + +func (c *Cli) ClipWrite(site string) error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/clip/write?str=%s", site), nil) + return err +} + +func (c *Cli) MouseClick() error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/click"), nil) + return err +} +func (c *Cli) MouseMove(x, y int) error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/move?x=%d&y=%d", x, y), nil) + return err +} +func (c *Cli) MouseMoveRelative(x, y int) error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/moverelative?x=%d&y=%d", x, y), nil) + return err +} +func (c *Cli) MouseClickRelative(x, y int) error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickatrelative?x=%d&y=%d", x, y), nil) + return err +} +func (c *Cli) MouseClickAt(x, y int) error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickat?x=%d&y=%d", x, y), nil) + return err +} +func (c *Cli) ScreenClick(f string) error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/click?f=%s", f), nil) + return err +} +func (c *Cli) ScreenClickCenter(f string) error { + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/clickcenter?f=%s", f), nil) + return err +} +func (c *Cli) ScreenFind(f string) (ret map[string]interface{}, err error) { + ret = make(map[string]interface{}) + err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/find?f=%s", f), &ret) + return +} + +func (c *Cli) KBTap(t string) (map[string]interface{}, error) { + /*Envia uma tecla ou teclas para serem clicadas no componente com foco onde o robo é executado + Em caso de teclas alteradoras, elas devem ser sempre posicionadas apos a tecla alvo. + Dessa forma, para enviar ALT+d, vc envia o string "d,alt". Para enviar C maiusculo, vc utiiliza + "c,shift". + + Referencia das teclas e respectivos strings: + + "`": 41, + "1": 2, + "2": 3, + "3": 4, + "4": 5, + "5": 6, + "6": 7, + "7": 8, + "8": 9, + "9": 10, + "0": 11, + "-": 12, + "+": 13, + // + "q": 16, + "w": 17, + "e": 18, + "r": 19, + "t": 20, + "y": 21, + "u": 22, + "i": 23, + "o": 24, + "p": 25, + "[": 26, + "]": 27, + "\\": 43, + // + "a": 30, + "s": 31, + "d": 32, + "f": 33, + "g": 34, + "h": 35, + "j": 36, + "k": 37, + "l": 38, + ";": 39, + "'": 40, + // + "z": 44, + "x": 45, + "c": 46, + "v": 47, + "b": 48, + "n": 49, + "m": 50, + ",": 51, + ".": 52, + "/": 53, + // + "f1": 59, + "f2": 60, + "f3": 61, + "f4": 62, + "f5": 63, + "f6": 64, + "f7": 65, + "f8": 66, + "f9": 67, + "f10": 68, + "f11": 69, + "f12": 70, + // more + "esc": 1, + "delete": 14, + "tab": 15, + "ctrl": 29, + "control": 29, + "alt": 56, + "space": 57, + "shift": 42, + "rshift": 54, + "enter": 28, + // + "cmd": 3675, + "command": 3675, + "rcmd": 3676, + "ralt": 3640, + // + "up": 57416, + "down": 57424, + "left": 57419, + "right": 57421, + */ + + ret := make(map[string]interface{}) + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/tap?str=%s", t), &ret) + return ret, err +} + +func (c *Cli) KBType(t string) (map[string]interface{}, error) { + /* Semelhante a tap, mas envia textos completos. + ***ATENCAO*** Esse metodo usa urlencoding, dessa forma caracteres serao codificados para envio. # virará %23 + por exemplo. Ao chegar no robo passrão pelo decoding análogo. */ + + ret := make(map[string]interface{}) + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/type?str=%s", t), &ret) + return ret, err +} + +func (c *Cli) ScreenWait(f string, m int) (ret map[string]interface{}, err error) { + ret = make(map[string]interface{}) + err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/wait?f=%s&m=%d", f, m), &ret) + return +} +func (c *Cli) ScreenWaitClick(f string, m int) (ret map[string]interface{}, err error) { + ret = make(map[string]interface{}) + err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/waitclick?f=%s&m=%d", f, m), &ret) + return +} +func (c *Cli) ScreenWaitClickCenter(f string, m int) (ret map[string]interface{}, err error) { + ret = make(map[string]interface{}) + err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/waitclickcenter?f=%s&m=%d", f, m), &ret) + return +} + +func NewCli() *Cli { + ret := &Cli{cli: api.NewCli()} + return ret +} diff --git a/api/wingui/cli.go b/api/wingui/cli.go index 81456b2..02b014c 100644 --- a/api/wingui/cli.go +++ b/api/wingui/cli.go @@ -2,6 +2,7 @@ package wingui import ( "fmt" + "go.digitalcircle.com.br/open/replaycli-go/api" ) @@ -24,6 +25,13 @@ func (c *Cli) ClipWrite(site string) error { return err } +func (c *Cli) Ocr_screen(l string) (map[string]interface{}, error) { + d := 0 + ret := make(map[string]interface{}) + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/ocr/screen?l=%s&d=%d", l, d), &ret) + return ret, err +} + func (c *Cli) MouseClick() error { err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/mouse/click"), nil) return err @@ -59,11 +67,114 @@ func (c *Cli) ScreenFind(f string) (ret map[string]interface{}, err error) { } func (c *Cli) KBTap(t string) (map[string]interface{}, error) { + /*Envia uma tecla ou teclas para serem clicadas no componente com foco onde o robo é executado + Em caso de teclas alteradoras, elas devem ser sempre posicionadas apos a tecla alvo. + Dessa forma, para enviar ALT+d, vc envia o string "d,alt". Para enviar C maiusculo, vc utiiliza + "c,shift". + + Referencia das teclas e respectivos strings: + + "`": 41, + "1": 2, + "2": 3, + "3": 4, + "4": 5, + "5": 6, + "6": 7, + "7": 8, + "8": 9, + "9": 10, + "0": 11, + "-": 12, + "+": 13, + // + "q": 16, + "w": 17, + "e": 18, + "r": 19, + "t": 20, + "y": 21, + "u": 22, + "i": 23, + "o": 24, + "p": 25, + "[": 26, + "]": 27, + "\\": 43, + // + "a": 30, + "s": 31, + "d": 32, + "f": 33, + "g": 34, + "h": 35, + "j": 36, + "k": 37, + "l": 38, + ";": 39, + "'": 40, + // + "z": 44, + "x": 45, + "c": 46, + "v": 47, + "b": 48, + "n": 49, + "m": 50, + ",": 51, + ".": 52, + "/": 53, + // + "f1": 59, + "f2": 60, + "f3": 61, + "f4": 62, + "f5": 63, + "f6": 64, + "f7": 65, + "f8": 66, + "f9": 67, + "f10": 68, + "f11": 69, + "f12": 70, + // more + "esc": 1, + "delete": 14, + "tab": 15, + "ctrl": 29, + "control": 29, + "alt": 56, + "space": 57, + "shift": 42, + "rshift": 54, + "enter": 28, + // + "cmd": 3675, + "command": 3675, + "rcmd": 3676, + "ralt": 3640, + // + "up": 57416, + "down": 57424, + "left": 57419, + "right": 57421, + */ + ret := make(map[string]interface{}) err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/tap?str=%s", t), &ret) return ret, err } +func (c *Cli) KBType(t string) (map[string]interface{}, error) { + /* Semelhante a tap, mas envia textos completos. + ***ATENCAO*** Esse metodo usa urlencoding, dessa forma caracteres serao codificados para envio. # virará %23 + por exemplo. Ao chegar no robo passrão pelo decoding análogo. */ + + ret := make(map[string]interface{}) + err := c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/kb/type?str=%s", t), &ret) + return ret, err +} + func (c *Cli) ScreenWait(f string, m int) (ret map[string]interface{}, err error) { ret = make(map[string]interface{}) err = c.cli.HttpJsonGet(fmt.Sprintf("/ipc/wingui/screen/wait?f=%s&m=%d", f, m), &ret)