add more key toggle function

This commit is contained in:
vcaesar 2021-09-15 11:43:34 -04:00
parent 51661803b1
commit 657cbe4701

View File

@ -63,6 +63,7 @@ import (
"unsafe"
// "syscall"
"math/rand"
"os/exec"
"github.com/go-vgo/robotgo/clipboard"
@ -697,6 +698,23 @@ func KeyToggle(key string, args ...string) string {
return C.GoString(str)
}
// KeyPress press key string
func KeyPress(key string) {
KeyDown(key)
Sleep(15 + rand.Intn(10))
KeyUp(key)
}
// KeyDown press down a key
func KeyDown(key string) {
KeyToggle(key, "down")
}
// KeyUp press up a key
func KeyUp(key string) {
KeyToggle(key, "up")
}
// ReadAll read string from clipboard
func ReadAll() (string, error) {
return clipboard.ReadAll()