mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
add hook example to robotgo examples
This commit is contained in:
parent
1eb7c942a9
commit
56ef33d171
42
examples/hook/main.go
Normal file
42
examples/hook/main.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user