go-vgo / robotgo

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

If you press a key such as left or right once, the "fn" key remains pressed thereafter. #614

Open yowpark opened 1 year ago

yowpark commented 1 year ago
package main

import (
    "github.com/go-vgo/robotgo"
)

func run() {
    robotgo.Sleep(5)

    seqs := [][]string{
        {"left"},
        {"f"},
        {"left", "up"},
        {"f", "up"},
    }

    for _, s := range seqs {
        var metaInterfaces []interface{}
        for i := 1; i < len(s); i++ {
            metaInterfaces = append(metaInterfaces, s[i])
        }
        robotgo.KeyToggle(s[0], metaInterfaces...)
        robotgo.MilliSleep(300)

        // with robotgo under v1.0.0-beta5
        // sExceptFirst := s[1:]
        // robotgo.KeyToggle(s[0], sExceptFirst...)
        // robotgo.MilliSleep(300)
    }
}

func main() {
    run()
}

Description

In the macOS environment, if you press the left or right key, the fn key has been pressed since then, so even if you simply press the "f" key, the "fn + f" key is pressed and the app changes to full screen.

After executing the above code with go run ., go to a web browser such as Chrome or Safari and click the url inputfield. If normal, the keyboard caret should move to the left and the letter f should be entered. However, the letter f is not entered and apps such as Chrome or Safari change to full screen.

It was possible to reproduce from v1.0.0-beta5 or higher, but could not be reproduced from v1.0.0-beta4 or lower.