Refactoring key example code

This commit is contained in:
vcaesar 2018-10-07 12:09:37 -04:00
parent dd52f408d9
commit 044ed50e53

View File

@ -17,11 +17,7 @@ import (
// "go-vgo/robotgo" // "go-vgo/robotgo"
) )
func key() { func typeStr() {
////////////////////////////////////////////////////////////////////////////////
// Control the keyboard
////////////////////////////////////////////////////////////////////////////////
// importing "Hello World" // importing "Hello World"
robotgo.TypeString("Hello World") robotgo.TypeString("Hello World")
@ -37,7 +33,9 @@ func key() {
robotgo.UnicodeType(ustr) robotgo.UnicodeType(ustr)
robotgo.PasteStr(" 粘贴字符串, paste") robotgo.PasteStr(" 粘贴字符串, paste")
}
func keyTap() {
// press "enter" // press "enter"
robotgo.KeyTap("enter") robotgo.KeyTap("enter")
robotgo.KeyTap("a", "control") robotgo.KeyTap("a", "control")
@ -58,12 +56,16 @@ func key() {
robotgo.KeyTap("m", "command") robotgo.KeyTap("m", "command")
robotgo.KeyTap("f1", "control") robotgo.KeyTap("f1", "control")
robotgo.KeyTap("a", "control") robotgo.KeyTap("a", "control")
}
func keyToggle() {
robotgo.KeyToggle("a", "down") robotgo.KeyToggle("a", "down")
robotgo.KeyToggle("a", "down", "alt") robotgo.KeyToggle("a", "down", "alt")
robotgo.KeyToggle("a", "down", "alt", "command") robotgo.KeyToggle("a", "down", "alt", "command")
robotgo.KeyToggle("enter", "down") robotgo.KeyToggle("enter", "down")
}
func cilp() {
robotgo.TypeString("en") robotgo.TypeString("en")
// write string to clipboard // write string to clipboard
@ -75,6 +77,19 @@ func key() {
} }
} }
func key() {
////////////////////////////////////////////////////////////////////////////////
// Control the keyboard
////////////////////////////////////////////////////////////////////////////////
typeStr()
keyTap()
keyToggle()
cilp()
}
func main() { func main() {
key() key()
} }