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