-
Notifications
You must be signed in to change notification settings - Fork 890
/
main.go
134 lines (104 loc) · 2.98 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Copyright 2016 The go-vgo Project Developers. 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> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
// "go-vgo/robotgo"
)
func typeStr() {
// typing "Hello World"
robotgo.TypeStr("Hello World!", 0, 1)
robotgo.KeySleep = 100
robotgo.TypeStr("だんしゃり")
robotgo.TypeStr("Hi galaxy, hi stars, hi MT.Rainier, hi sea. こんにちは世界.")
robotgo.TypeStr("So, hi, bye! 你好, 再见!")
robotgo.Sleep(1)
robotgo.TypeStr("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")
fmt.Println("PasteStr: ", err)
}
func keyTap() {
// press "enter"
robotgo.KeyTap("enter")
robotgo.KeyTap(robotgo.Enter)
robotgo.KeySleep = 200
robotgo.KeyTap("a")
robotgo.MilliSleep(100)
robotgo.KeyTap("a", "ctrl")
// hide window
err := robotgo.KeyTap("h", "cmd")
if err != nil {
fmt.Println("robotgo.KeyTap run error is: ", err)
}
robotgo.KeyTap("h", "cmd")
// press "i", "alt", "command" Key combination
robotgo.KeyTap(robotgo.KeyI, robotgo.Alt, robotgo.Cmd)
robotgo.KeyTap("i", "alt", "cmd")
arr := []string{"alt", "cmd"}
robotgo.KeyTap("i", arr)
robotgo.KeyTap("i", arr)
robotgo.KeyTap("i", "cmd", " alt", "shift")
// close window
robotgo.KeyTap("w", "cmd")
// minimize window
robotgo.KeyTap("m", "cmd")
robotgo.KeyTap("f1", "ctrl")
robotgo.KeyTap("a", "control")
}
func special() {
robotgo.TypeStr("{}")
robotgo.KeyTap("[", "]")
robotgo.KeyToggle("(")
robotgo.KeyToggle("(", "up")
}
func keyToggle() {
// robotgo.KeySleep = 150
robotgo.KeyToggle(robotgo.KeyA)
robotgo.KeyToggle("a", "down", "alt")
robotgo.Sleep(1)
robotgo.KeyToggle("a", "up", "alt", "cmd")
robotgo.MilliSleep(100)
robotgo.KeyToggle("q", "up", "alt", "cmd", "shift")
err := robotgo.KeyToggle(robotgo.Enter)
if err != nil {
fmt.Println("robotgo.KeyToggle run error is: ", err)
}
}
func cilp() {
// robotgo.TypeStr("en")
// write string to clipboard
e := robotgo.WriteAll("テストする")
if e != nil {
fmt.Println("robotgo.WriteAll err is: ", e)
}
// read string from clipboard
text, err := robotgo.ReadAll()
if err != nil {
fmt.Println("robotgo.ReadAll err is: ", err)
}
fmt.Println("text: ", text)
}
func key() {
////////////////////////////////////////////////////////////////////////////////
// Control the keyboard
////////////////////////////////////////////////////////////////////////////////
typeStr()
special()
keyTap()
keyToggle()
cilp()
}
func main() {
key()
}