Update: simply the api and update copyright head

This commit is contained in:
vcaesar 2025-11-28 06:55:54 -08:00
parent 468a84d408
commit 18f032b809
9 changed files with 74 additions and 33 deletions

View file

@ -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])

View file

@ -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("(")

43
key.go
View file

@ -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)
}

View file

@ -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 <LICENSE-APACHE or

View file

@ -1,3 +1,14 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-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"

View file

@ -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 <LICENSE-APACHE or

View file

@ -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 <LICENSE-APACHE or

View file

@ -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 <LICENSE-APACHE or

View file

@ -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 <LICENSE-APACHE or