mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Refactoring key example code
This commit is contained in:
parent
dd52f408d9
commit
044ed50e53
@ -17,11 +17,7 @@ import (
|
||||
// "go-vgo/robotgo"
|
||||
)
|
||||
|
||||
func key() {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Control the keyboard
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
func typeStr() {
|
||||
// importing "Hello World"
|
||||
robotgo.TypeString("Hello World")
|
||||
|
||||
@ -37,7 +33,9 @@ func key() {
|
||||
robotgo.UnicodeType(ustr)
|
||||
|
||||
robotgo.PasteStr(" 粘贴字符串, paste")
|
||||
}
|
||||
|
||||
func keyTap() {
|
||||
// press "enter"
|
||||
robotgo.KeyTap("enter")
|
||||
robotgo.KeyTap("a", "control")
|
||||
@ -58,12 +56,16 @@ func key() {
|
||||
robotgo.KeyTap("m", "command")
|
||||
robotgo.KeyTap("f1", "control")
|
||||
robotgo.KeyTap("a", "control")
|
||||
}
|
||||
|
||||
func keyToggle() {
|
||||
robotgo.KeyToggle("a", "down")
|
||||
robotgo.KeyToggle("a", "down", "alt")
|
||||
robotgo.KeyToggle("a", "down", "alt", "command")
|
||||
robotgo.KeyToggle("enter", "down")
|
||||
}
|
||||
|
||||
func cilp() {
|
||||
robotgo.TypeString("en")
|
||||
|
||||
// write string to clipboard
|
||||
@ -75,6 +77,19 @@ func key() {
|
||||
}
|
||||
}
|
||||
|
||||
func key() {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Control the keyboard
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typeStr()
|
||||
|
||||
keyTap()
|
||||
keyToggle()
|
||||
|
||||
cilp()
|
||||
}
|
||||
|
||||
func main() {
|
||||
key()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user