diff --git a/README.md b/README.md index 30844ac..868915a 100644 --- a/README.md +++ b/README.md @@ -216,12 +216,12 @@ import ( ) func main() { - robotgo.TypeStr("Hello World") - robotgo.TypeStr("だんしゃり", 0, 1) - // robotgo.TypeStr("テストする") + robotgo.Type("Hello World") + robotgo.Type("だんしゃり", 0, 1) + // robotgo.Type("テストする") - robotgo.TypeStr("Hi, Seattle space needle, Golden gate bridge, One world trade center.") - robotgo.TypeStr("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.") + robotgo.Type("Hi, Seattle space needle, Golden gate bridge, One world trade center.") + robotgo.Type("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.") robotgo.Sleep(1) // ustr := uint32(robotgo.CharCodeAt("Test", 0)) @@ -229,7 +229,7 @@ func main() { robotgo.KeySleep = 100 robotgo.KeyTap("enter") - // robotgo.TypeStr("en") + // robotgo.Type("en") robotgo.KeyTap("i", "alt", "cmd") arr := []string{"alt", "cmd"} @@ -473,7 +473,7 @@ func main() { fmt.Println("pids... ", fpid) if len(fpid) > 0 { - robotgo.TypeStr("Hi galaxy!", fpid[0]) + robotgo.Type("Hi galaxy!", fpid[0]) robotgo.KeyTap("a", fpid[0], "cmd") robotgo.KeyToggle("a", fpid[0]) diff --git a/examples/key/main.go b/examples/key/main.go index 4cc39be..17bf63d 100644 --- a/examples/key/main.go +++ b/examples/key/main.go @@ -20,21 +20,21 @@ import ( func typeStr() { // typing "Hello World" - robotgo.TypeStr("Hello World!", 0, 1) + robotgo.Type("Hello World!", 0, 1) robotgo.KeySleep = 100 - robotgo.TypeStr("だんしゃり") + robotgo.Type("だんしゃり") - robotgo.TypeStr("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.") - robotgo.TypeStr("So, hi, bye! 你好, 再见!") + robotgo.Type("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.") + robotgo.Type("So, hi, bye! 你好, 再见!") robotgo.Sleep(1) - robotgo.TypeStr("Hi, Seattle space needle, Golden gate bridge, One world trade center.") + robotgo.Type("Hi, Seattle space needle, Golden gate bridge, One world trade center.") robotgo.MilliSleep(100) ustr := uint32(robotgo.CharCodeAt("So, hi, bye!", 0)) robotgo.UnicodeType(ustr) - err := robotgo.PasteStr("paste string") + err := robotgo.Paste("paste string") fmt.Println("PasteStr: ", err) } @@ -76,7 +76,7 @@ func keyTap() { } func special() { - robotgo.TypeStr("{}") + robotgo.Type("{}") robotgo.KeyTap("[", "]") robotgo.KeyToggle("(") diff --git a/key.go b/key.go index 2a1559d..1e8e297 100644 --- a/key.go +++ b/key.go @@ -670,15 +670,22 @@ func inputUTF(str string) { C.free(unsafe.Pointer(cstr)) } -// TypeStr send a string (supported UTF-8) +// TypeStr tap a string // -// robotgo.TypeStr(string: "The string to send", int: pid, "milli_sleep time", "x11 option") +// Deprecated: use the Type() +func TypeStr(str string, args ...int) { + Type(str, args...) +} + +// Type type a string (supported UTF-8) +// +// robotgo.Type(string: "The string to send", int: pid, "milli_sleep time", "x11 option") // // Examples: // -// 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) { +// robotgo.Type("abc@123, Hi galaxy, こんにちは") +// robotgo.Type("To be or not to be, this is questions.", pid int) +func Type(str string, args ...int) { var tm, tm1 = 0, 7 if len(args) > 1 { @@ -719,14 +726,25 @@ func TypeStr(str string, args ...int) { MilliSleep(KeySleep) } -// PasteStr paste a string (support UTF-8), -// write the string to clipboard and tap `cmd + v` +// PasteStr paste a string +// +// Deprecated: use the Paste() func PasteStr(str string) error { + return Paste(str) +} + +// Paste paste a string (supported UTF-8), +// write the string to clipboard and tap `cmd + v` +func Paste(str string) error { err := clipboard.WriteAll(str) if err != nil { return err } + return CmdV() +} +// CmdV tap key command + v or control + v +func CmdV() error { if runtime.GOOS == "darwin" { return KeyTap("v", "command") } @@ -734,9 +752,16 @@ func PasteStr(str string) error { return KeyTap("v", "control") } -// TypeStrDelay type string with delayed -// And you can use robotgo.KeySleep = 100 to delayed not this function +// TypeStrDelay type string width delay +// +// Deprecated: use the TypeDelay() func TypeStrDelay(str string, delay int) { + TypeDelay(str, delay) +} + +// TypeDelay type string with delayed +// And you can use robotgo.KeySleep = 100 to delayed not this function +func TypeDelay(str string, delay int) { TypeStr(str) MilliSleep(delay) } diff --git a/key/keypress_c.h b/key/keypress_c.h index 060f5f4..b93eeaf 100644 --- a/key/keypress_c.h +++ b/key/keypress_c.h @@ -1,5 +1,6 @@ -// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright (c) 2016-2025 AtomAI, All rights reserved. +// +// See the COPYRIGHT file at the top-level directory of this distribution and at // https://github.com/go-vgo/robotgo/blob/master/LICENSE // // Licensed under the Apache License, Version 2.0 +// +// This file may not be copied, modified, or distributed +// except according to those terms. + #include "mouse.h" #include "../base/deadbeef_rand.h" #include "../base/microsleep.h" diff --git a/screen/goScreen.h b/screen/goScreen.h index a4bab45..4adce3b 100644 --- a/screen/goScreen.h +++ b/screen/goScreen.h @@ -1,5 +1,6 @@ -// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at +// Copyright (c) 2016-2025 AtomAI, All rights reserved. +// +// See the COPYRIGHT file at the top-level directory of this distribution and at // https://github.com/go-vgo/robotgo/blob/master/LICENSE // // Licensed under the Apache License, Version 2.0