mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-30 22:13:54 +00:00
update keycode type use uint16 with gohook, not type convert
This commit is contained in:
parent
bec66ba51f
commit
f765226230
8
hook.go
8
hook.go
@ -47,7 +47,7 @@ func AddEvent(key string) bool {
|
||||
}
|
||||
|
||||
if len(key) > 1 && !mouseBool {
|
||||
key = strconv.Itoa(Keycode[key].(int))
|
||||
key = strconv.Itoa(int(Keycode[key]))
|
||||
}
|
||||
|
||||
geve := hook.AddEvent(key)
|
||||
@ -93,7 +93,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 := Keycode[arr[i]]
|
||||
|
||||
if e.Kind == hook.KeyHold && e.Keycode == ukey {
|
||||
k++
|
||||
@ -115,7 +115,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 == Keycode[key] {
|
||||
hook.End()
|
||||
// k = 0
|
||||
break
|
||||
@ -148,7 +148,7 @@ func AddMouse(btn string, x ...int16) bool {
|
||||
ct = true
|
||||
}
|
||||
|
||||
if ct && e.Kind == hook.MouseDown && int(e.Button) == ukey {
|
||||
if ct && e.Kind == hook.MouseDown && e.Button == ukey {
|
||||
hook.End()
|
||||
break
|
||||
}
|
||||
|
@ -10,8 +10,10 @@
|
||||
|
||||
package robotgo
|
||||
|
||||
type uMap map[string]uint16
|
||||
|
||||
// MouseMap robotgo hook mouse's code map
|
||||
var MouseMap = Map{
|
||||
var MouseMap = uMap{
|
||||
"left": 1,
|
||||
"right": 2,
|
||||
"center": 3,
|
||||
@ -22,7 +24,7 @@ var MouseMap = Map{
|
||||
}
|
||||
|
||||
// Keycode robotgo hook key's code map
|
||||
var Keycode = Map{
|
||||
var Keycode = uMap{
|
||||
"`": 41,
|
||||
"1": 2,
|
||||
"2": 3,
|
||||
|
Loading…
Reference in New Issue
Block a user