Update: Update README.md and godoc

This commit is contained in:
vcaesar 2022-11-28 13:40:01 -08:00
parent 7aa5beb8f7
commit f911550742
3 changed files with 10 additions and 4 deletions

View File

@ -68,10 +68,9 @@ xcode-select --install
Download the Mingw, then set system environment variables `C:\mingw64\bin` to the Path. Download the Mingw, then set system environment variables `C:\mingw64\bin` to the Path.
[Set environment variables to run GCC from command line](https://www.youtube.com/results?search_query=Set+environment+variables+to+run+GCC+from+command+line). [Set environment variables to run GCC from command line](https://www.youtube.com/results?search_query=Set+environment+variables+to+run+GCC+from+command+line).
`
```
Or the other GCC (But you should compile the "libpng" with yourself when use the bitmap.) Or the other GCC (But you should compile the "libpng" with yourself when use the bitmap.)
``` `
#### For everything else: #### For everything else:

2
doc.go
View File

@ -54,7 +54,7 @@ Keys are supported:
"f23" "f23"
"f24" "f24"
"cmd" is the "win" key for windows "cmd" this is the "win" key for windows
"lcmd" left command "lcmd" left command
"rcmd" right command "rcmd" right command
// "command" // "command"

7
key.go
View File

@ -30,6 +30,7 @@ import (
"github.com/vcaesar/tt" "github.com/vcaesar/tt"
) )
// Defining a bunch of constants.
const ( const (
// KeyA define key "a" // KeyA define key "a"
KeyA = "a" KeyA = "a"
@ -321,6 +322,7 @@ var keyNames = map[string]C.MMKeyCode{
// { NULL: C.K_NOT_A_KEY } // { NULL: C.K_NOT_A_KEY }
} }
// It sends a key press and release to the active application
func tapKeyCode(code C.MMKeyCode, flags C.MMKeyFlags, pid C.uintptr) { func tapKeyCode(code C.MMKeyCode, flags C.MMKeyFlags, pid C.uintptr) {
C.toggleKeyCode(code, true, flags, pid) C.toggleKeyCode(code, true, flags, pid)
MilliSleep(3) MilliSleep(3)
@ -459,6 +461,7 @@ func ToStrings(fields []interface{}) []string {
return res return res
} }
// toErr it converts a C string to a Go error
func toErr(str *C.char) error { func toErr(str *C.char) error {
gstr := C.GoString(str) gstr := C.GoString(str)
if gstr == "" { if gstr == "" {
@ -481,6 +484,8 @@ func toErr(str *C.char) error {
// //
// arr := []string{"alt", "command"} // arr := []string{"alt", "command"}
// robotgo.KeyTap("i", arr) // robotgo.KeyTap("i", arr)
//
// robotgo.KeyTap("k", pid int)
func KeyTap(key string, args ...interface{}) error { func KeyTap(key string, args ...interface{}) error {
var keyArr []string var keyArr []string
@ -525,6 +530,7 @@ func KeyTap(key string, args ...interface{}) error {
// robotgo.KeyToggle("a", "up") // robotgo.KeyToggle("a", "up")
// //
// robotgo.KeyToggle("a", "up", "alt", "cmd") // robotgo.KeyToggle("a", "up", "alt", "cmd")
// robotgo.KeyToggle("k", pid int)
func KeyToggle(key string, args ...interface{}) error { func KeyToggle(key string, args ...interface{}) error {
if len(key) > 0 && unicode.IsUpper([]rune(key)[0]) { if len(key) > 0 && unicode.IsUpper([]rune(key)[0]) {
@ -648,6 +654,7 @@ func inputUTF(str string) {
// Examples: // Examples:
// //
// robotgo.TypeStr("abc@123, Hi galaxy, こんにちは") // robotgo.TypeStr("abc@123, Hi galaxy, こんにちは")
// robotgo.TypeStr("To be or not to be, this is questions.", pid int)
func TypeStr(str string, args ...int) { func TypeStr(str string, args ...int) {
var tm, tm1 = 0, 7 var tm, tm1 = 0, 7