mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-30 22:13:54 +00:00
export hook keycode and add godoc
This commit is contained in:
parent
ada3ddc5e1
commit
7308e0c82e
@ -10,7 +10,8 @@
|
||||
|
||||
package robotgo
|
||||
|
||||
var mouseMap = Map{
|
||||
// MouseMap robotgo hook mouse's code map
|
||||
var MouseMap = Map{
|
||||
"left": 1,
|
||||
"right": 2,
|
||||
"center": 3,
|
||||
@ -20,7 +21,8 @@ var mouseMap = Map{
|
||||
"wheelRight": 7,
|
||||
}
|
||||
|
||||
var keycode = Map{
|
||||
// Keycode robotgo hook key's code map
|
||||
var Keycode = Map{
|
||||
"`": 41,
|
||||
"1": 2,
|
||||
"2": 3,
|
||||
|
@ -1281,7 +1281,7 @@ func AddEvent(key string) bool {
|
||||
}
|
||||
|
||||
if len(key) > 1 && !mouseBool {
|
||||
key = strconv.Itoa(keycode[key].(int))
|
||||
key = strconv.Itoa(Keycode[key].(int))
|
||||
}
|
||||
|
||||
geve := hook.AddEvent(key)
|
||||
@ -1327,7 +1327,7 @@ func AddEvents(key string, arr ...string) bool {
|
||||
l := len(arr)
|
||||
if l > 0 {
|
||||
for i := 0; i < l; i++ {
|
||||
ukey := uint16(keycode[arr[i]].(int))
|
||||
ukey := uint16(Keycode[arr[i]].(int))
|
||||
|
||||
if e.Kind == hook.KeyHold && e.Keycode == ukey {
|
||||
k++
|
||||
@ -1349,7 +1349,7 @@ func AddEvents(key string, arr ...string) bool {
|
||||
ct = true
|
||||
}
|
||||
|
||||
if ct && e.Kind == hook.KeyUp && e.Keycode == uint16(keycode[key].(int)) {
|
||||
if ct && e.Kind == hook.KeyUp && e.Keycode == uint16(Keycode[key].(int)) {
|
||||
hook.End()
|
||||
// k = 0
|
||||
break
|
||||
@ -1368,7 +1368,7 @@ func AddEvents(key string, arr ...string) bool {
|
||||
// robotgo.AddMouse("left", 100, 100)
|
||||
func AddMouse(btn string, x ...int16) bool {
|
||||
s := hook.Start()
|
||||
ukey := mouseMap[btn]
|
||||
ukey := MouseMap[btn]
|
||||
|
||||
ct := false
|
||||
for {
|
||||
|
Loading…
Reference in New Issue
Block a user