mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
Add uppercase key support with default and Update godoc
This commit is contained in:
parent
2f79ebe879
commit
34d0fbf4bc
25
key.go
25
key.go
@ -23,6 +23,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo/clipboard"
|
"github.com/go-vgo/robotgo/clipboard"
|
||||||
@ -444,12 +445,16 @@ func toErr(str *C.char) error {
|
|||||||
// arr := []string{"alt", "command"}
|
// arr := []string{"alt", "command"}
|
||||||
// robotgo.KeyTap("i", arr)
|
// robotgo.KeyTap("i", arr)
|
||||||
//
|
//
|
||||||
func KeyTap(tapKey string, args ...interface{}) error {
|
func KeyTap(key string, args ...interface{}) error {
|
||||||
var keyArr []string
|
var keyArr []string
|
||||||
|
|
||||||
tapKey = strings.ToLower(tapKey)
|
if len(key) > 0 && unicode.IsUpper([]rune(key)[0]) {
|
||||||
if _, ok := Special[tapKey]; ok {
|
args = append(args, "shift")
|
||||||
tapKey = Special[tapKey]
|
}
|
||||||
|
|
||||||
|
key = strings.ToLower(key)
|
||||||
|
if _, ok := Special[key]; ok {
|
||||||
|
key = Special[key]
|
||||||
if len(args) <= 0 {
|
if len(args) <= 0 {
|
||||||
args = append(args, "shift")
|
args = append(args, "shift")
|
||||||
}
|
}
|
||||||
@ -463,7 +468,7 @@ func KeyTap(tapKey string, args ...interface{}) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyTaps(tapKey, keyArr)
|
return keyTaps(key, keyArr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyToggle toggle the keyboard, if there not have args default is "down"
|
// KeyToggle toggle the keyboard, if there not have args default is "down"
|
||||||
@ -482,6 +487,10 @@ func KeyToggle(key string, args ...string) error {
|
|||||||
args = append(args, "down")
|
args = append(args, "down")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(key) > 0 && unicode.IsUpper([]rune(key)[0]) {
|
||||||
|
args = append(args, "shift")
|
||||||
|
}
|
||||||
|
|
||||||
key = strings.ToLower(key)
|
key = strings.ToLower(key)
|
||||||
if _, ok := Special[key]; ok {
|
if _, ok := Special[key]; ok {
|
||||||
key = Special[key]
|
key = Special[key]
|
||||||
@ -573,12 +582,12 @@ func inputUTF(str string) {
|
|||||||
C.free(unsafe.Pointer(cstr))
|
C.free(unsafe.Pointer(cstr))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeStr send a string, support UTF-8
|
// TypeStr send a string, supported UTF-8
|
||||||
//
|
//
|
||||||
// robotgo.TypeStr(string: The string to send, int: milli_sleep time, x11 option)
|
// robotgo.TypeStr(string: "The string to send", int: "milli_sleep time", "x11 option")
|
||||||
//
|
//
|
||||||
// Examples:
|
// Examples:
|
||||||
// robotgo.TypeStr("abc@123, hi, こんにちは")
|
// robotgo.TypeStr("abc@123, hi galaxy, こんにちは")
|
||||||
//
|
//
|
||||||
func TypeStr(str string, args ...int) {
|
func TypeStr(str string, args ...int) {
|
||||||
var tm, tm1 = 0, 7
|
var tm, tm1 = 0, 7
|
||||||
|
Loading…
Reference in New Issue
Block a user