mirror of
https://github.com/robotn/gohook.git
synced 2025-02-21 20:44:29 +08:00
Update: update examples and README.md
This commit is contained in:
parent
0d69fe6a36
commit
f049036b8c
@ -45,7 +45,11 @@ func add() {
|
||||
|
||||
fmt.Println("--- Please press w---")
|
||||
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
|
||||
fmt.Println("w")
|
||||
fmt.Println("keyDown: ", "w")
|
||||
})
|
||||
|
||||
hook.Register(hook.KeyUp, []string{"w"}, func(e hook.Event) {
|
||||
fmt.Println("keyUp: ", "w")
|
||||
})
|
||||
|
||||
s := hook.Start()
|
||||
|
@ -6,6 +6,15 @@ import (
|
||||
hook "github.com/robotn/gohook"
|
||||
)
|
||||
|
||||
func main() {
|
||||
registerEvent()
|
||||
|
||||
base()
|
||||
|
||||
add()
|
||||
addMouse()
|
||||
}
|
||||
|
||||
func registerEvent() {
|
||||
fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
|
||||
hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
|
||||
@ -15,7 +24,11 @@ func registerEvent() {
|
||||
|
||||
fmt.Println("--- Please press w ---")
|
||||
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
|
||||
fmt.Println("w-")
|
||||
fmt.Println("KeyDown: ", "w-")
|
||||
})
|
||||
|
||||
hook.Register(hook.KeyUp, []string{"w"}, func(e hook.Event) {
|
||||
fmt.Println("KeyUp: ", "w")
|
||||
})
|
||||
|
||||
s := hook.Start()
|
||||
@ -69,12 +82,3 @@ func base() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
registerEvent()
|
||||
|
||||
base()
|
||||
|
||||
add()
|
||||
addMouse()
|
||||
}
|
||||
|
2
hook.go
2
hook.go
@ -118,7 +118,6 @@ func Register(when uint8, cmds []string, cb func(Event)) {
|
||||
key := len(used)
|
||||
used = append(used, key)
|
||||
tmp := []uint16{}
|
||||
|
||||
uptmp := []uint16{}
|
||||
|
||||
for _, v := range cmds {
|
||||
@ -160,7 +159,6 @@ func Process(evChan <-chan Event) (out chan bool) {
|
||||
uppressed = make(map[uint16]bool, 256)
|
||||
cbs[v](ev)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user