mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
add more key toggle function
This commit is contained in:
parent
51661803b1
commit
657cbe4701
18
robotgo.go
18
robotgo.go
@ -63,6 +63,7 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
// "syscall"
|
// "syscall"
|
||||||
|
"math/rand"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo/clipboard"
|
"github.com/go-vgo/robotgo/clipboard"
|
||||||
@ -697,6 +698,23 @@ func KeyToggle(key string, args ...string) string {
|
|||||||
return C.GoString(str)
|
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
|
// ReadAll read string from clipboard
|
||||||
func ReadAll() (string, error) {
|
func ReadAll() (string, error) {
|
||||||
return clipboard.ReadAll()
|
return clipboard.ReadAll()
|
||||||
|
Loading…
Reference in New Issue
Block a user