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