mirror of
https://github.com/robotn/gohook.git
synced 2024-11-22 11:36:47 +08:00
43 lines
492 B
Go
43 lines
492 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
hook "github.com/robotn/gohook"
|
|
)
|
|
|
|
// hook listen and return values using detailed examples
|
|
func add() {
|
|
s := hook.Start()
|
|
defer hook.End()
|
|
|
|
ct := false
|
|
for {
|
|
i := <-s
|
|
|
|
if i.Kind == hook.KeyHold && i.Rawcode == 59 {
|
|
ct = true
|
|
}
|
|
|
|
if ct && i.Rawcode == 12 {
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// base hook example
|
|
func base() {
|
|
EvChan := hook.Start()
|
|
defer hook.End()
|
|
|
|
for ev := range EvChan {
|
|
fmt.Println("hook: ", ev)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
base()
|
|
|
|
add()
|
|
}
|