mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-30 22:13:54 +00:00
Update: update godoc and fixed typo
This commit is contained in:
parent
e9b5a9251e
commit
c3cda41c2d
@ -519,9 +519,9 @@ Some discussions and questions, please see [issues/228](https://github.com/go-vg
|
||||
## Plans
|
||||
- Refactor some C code to Go (such as x11, windows)
|
||||
- Better multiscreen support
|
||||
- Waylad supports
|
||||
- Wayland support
|
||||
- Update Window Handle
|
||||
- Try support Android and IOS
|
||||
- Try to support Android and IOS
|
||||
|
||||
## Contributors
|
||||
|
||||
|
28
key.go
28
key.go
@ -201,7 +201,7 @@ const (
|
||||
LightsKbdDown = "lights_kbd_down"
|
||||
)
|
||||
|
||||
// keyNames define MMKeyCode map
|
||||
// keyNames define a map of key names to MMKeyCode
|
||||
var keyNames = map[string]C.MMKeyCode{
|
||||
"backspace": C.K_BACKSPACE,
|
||||
"delete": C.K_DELETE,
|
||||
@ -441,7 +441,7 @@ func keyToggles(k string, keyArr []string, pid int) error {
|
||||
|
||||
*/
|
||||
|
||||
// ToInterfaces []string to []interface{}
|
||||
// ToInterfaces convert []string to []interface{}
|
||||
func ToInterfaces(fields []string) []interface{} {
|
||||
res := make([]interface{}, 0, len(fields))
|
||||
for _, s := range fields {
|
||||
@ -450,7 +450,7 @@ func ToInterfaces(fields []string) []interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
// ToStrings []interface{} to []string
|
||||
// ToStrings convert []interface{} to []string
|
||||
func ToStrings(fields []interface{}) []string {
|
||||
res := make([]string, 0, len(fields))
|
||||
for _, s := range fields {
|
||||
@ -467,19 +467,20 @@ func toErr(str *C.char) error {
|
||||
return errors.New(gstr)
|
||||
}
|
||||
|
||||
// KeyTap tap the keyboard code;
|
||||
// KeyTap taps the keyboard code;
|
||||
//
|
||||
// See keys:
|
||||
//
|
||||
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// robotgo.KeySleep = 100 // 100 millisecond
|
||||
// robotgo.KeyTap("a")
|
||||
// robotgo.KeyTap("i", "alt", "command")
|
||||
//
|
||||
// arr := []string{"alt", "command"}
|
||||
// robotgo.KeyTap("i", arr)
|
||||
//
|
||||
func KeyTap(key string, args ...interface{}) error {
|
||||
var keyArr []string
|
||||
|
||||
@ -512,17 +513,18 @@ func KeyTap(key string, args ...interface{}) error {
|
||||
return keyTaps(key, keyArr, pid)
|
||||
}
|
||||
|
||||
// KeyToggle toggle the keyboard, if there not have args default is "down"
|
||||
// KeyToggle toggles the keyboard, if there not have args default is "down"
|
||||
//
|
||||
// See keys:
|
||||
//
|
||||
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// robotgo.KeyToggle("a")
|
||||
// robotgo.KeyToggle("a", "up")
|
||||
//
|
||||
// robotgo.KeyToggle("a", "up", "alt", "cmd")
|
||||
//
|
||||
func KeyToggle(key string, args ...interface{}) error {
|
||||
|
||||
if len(key) > 0 && unicode.IsUpper([]rune(key)[0]) {
|
||||
@ -633,13 +635,13 @@ func inputUTF(str string) {
|
||||
C.free(unsafe.Pointer(cstr))
|
||||
}
|
||||
|
||||
// TypeStr send a string, supported UTF-8
|
||||
// TypeStr send a string (supported UTF-8)
|
||||
//
|
||||
// robotgo.TypeStr(string: "The string to send", int: pid, "milli_sleep time", "x11 option")
|
||||
//
|
||||
// Examples:
|
||||
// robotgo.TypeStr("abc@123, Hi galaxy, こんにちは")
|
||||
//
|
||||
// robotgo.TypeStr("abc@123, Hi galaxy, こんにちは")
|
||||
func TypeStr(str string, args ...int) {
|
||||
var tm, tm1 = 0, 7
|
||||
|
||||
@ -681,7 +683,7 @@ func TypeStr(str string, args ...int) {
|
||||
MilliSleep(KeySleep)
|
||||
}
|
||||
|
||||
// PasteStr paste a string, support UTF-8,
|
||||
// PasteStr paste a string (support UTF-8),
|
||||
// write the string to clipboard and tap `cmd + v`
|
||||
func PasteStr(str string) error {
|
||||
err := clipboard.WriteAll(str)
|
||||
@ -696,7 +698,7 @@ func PasteStr(str string) error {
|
||||
return KeyTap("v", "control")
|
||||
}
|
||||
|
||||
// TypeStrDelay type string delayed
|
||||
// TypeStrDelay type string with delayed
|
||||
func TypeStrDelay(str string, delay int) {
|
||||
TypeStr(str)
|
||||
MilliSleep(delay)
|
||||
@ -704,7 +706,7 @@ func TypeStrDelay(str string, delay int) {
|
||||
|
||||
// Deprecated: use the TypeStr(),
|
||||
//
|
||||
// TypeStringDelayed type string delayed, Wno-deprecated
|
||||
// # TypeStringDelayed type string delayed, Wno-deprecated
|
||||
//
|
||||
// This function will be removed in version v1.0.0
|
||||
func TypeStringDelayed(str string, delay int) {
|
||||
@ -712,7 +714,7 @@ func TypeStringDelayed(str string, delay int) {
|
||||
TypeStrDelay(str, delay)
|
||||
}
|
||||
|
||||
// SetDelay set the key and mouse delay
|
||||
// SetDelay sets the key and mouse delay
|
||||
func SetDelay(d ...int) {
|
||||
v := 10
|
||||
if len(d) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user