go-vgo / robotgo

RobotGo, Go Native cross-platform RPA and GUI automation @vcaesar
Apache License 2.0
9.47k stars 862 forks source link

strange output for robotgo.TypeStr in event hanlder #586

Open hick opened 1 year ago

hick commented 1 year ago

based on the example code at event part, just add 2 lines of robotgo.TypeStr("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.") as the following in function add, the full code of function add is

func add() {
    fmt.Println("--- !! Please press ctrl + shift + q to stop hook ---")
    hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
        fmt.Println("ctrl-shift-q")
        robotgo.TypeStr("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.")  // the first line added
        //  press "ctrl + shift + q" then: 
        hook.End()
    })

    fmt.Println("--- Please press w---")
    hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
        fmt.Println("w")
        robotgo.TypeStr("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.") // the second line added
        // press "w" at first: 
    }) 

    s := hook.Start()
    <-hook.Process(s)
}

it's ok for pressing the keyboard "w", but not ok for press "ctrl + shift + q", as the following screenshot: the front part of that string "Hi galaxy, hi stars, hi MT.Rainier, hi sea. " has gone away:

image