mirror of
https://github.com/robotn/gohook.git
synced 2025-02-22 13:11:16 +08:00
replace all import and gofmt code
This commit is contained in:
parent
f0ddfd620c
commit
43543e0cff
18
README.md
18
README.md
@ -1,20 +1,18 @@
|
||||
# gohook
|
||||
|
||||
[](https://circleci.com/gh/cauefcr/gohook)
|
||||

|
||||
[](https://goreportcard.com/report/github.com/cauefcr/gohook)
|
||||
[](https://godoc.org/github.com/cauefcr/gohook)
|
||||
[](https://circleci.com/gh/robotn/gohook)
|
||||

|
||||
[](https://goreportcard.com/report/github.com/robotn/gohook)
|
||||
[](https://godoc.org/github.com/robotn/gohook)
|
||||
<!-- This is a work in progress. -->
|
||||
|
||||
Based on [libuiohook](https://github.com/kwhat/libuiohook)
|
||||
|
||||
```Go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"github.com/robotn/gohook"
|
||||
"github.com/cauefcr/gohook"
|
||||
|
||||
"github.com/robotn/gohook"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -24,4 +22,6 @@ func main() {
|
||||
fmt.Println(ev)
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
Based on [libuiohook](https://github.com/kwhat/libuiohook).
|
5
hook.go
5
hook.go
@ -151,3 +151,8 @@ func AddEvent(key string) int {
|
||||
|
||||
return geve
|
||||
}
|
||||
|
||||
// StopEvent stop event listener
|
||||
func StopEvent() {
|
||||
C.stop_event()
|
||||
}
|
||||
|
10
test/main.go
10
test/main.go
@ -4,13 +4,13 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cauefcr/gohook"
|
||||
"github.com/robotn/gohook"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := hook.Start()
|
||||
defer hook.End()
|
||||
tout := time.After(time.Hour*2)
|
||||
tout := time.After(time.Hour * 2)
|
||||
done := false
|
||||
for !done {
|
||||
select {
|
||||
@ -19,13 +19,13 @@ func main() {
|
||||
if i.Keychar == 'q' {
|
||||
tout = time.After(0)
|
||||
}
|
||||
fmt.Printf("%v key: %c:%v\n",i.Kind, i.Keychar,i.Rawcode)
|
||||
fmt.Printf("%v key: %c:%v\n", i.Kind, i.Keychar, i.Rawcode)
|
||||
} else if i.Kind >= hook.MouseDown && i.Kind < hook.MouseWheel {
|
||||
//fmt.Printf("x: %v, y: %v, button: %v\n", i.X, i.Y, i.Button)
|
||||
}else if i.Kind == hook.MouseWheel {
|
||||
} else if i.Kind == hook.MouseWheel {
|
||||
//fmt.Printf("x: %v, y: %v, button: %v, wheel: %v, rotation: %v\n", i.X, i.Y, i.Button,i.Amount,i.Rotation)
|
||||
} else {
|
||||
fmt.Printf("%+v\n",i)
|
||||
fmt.Printf("%+v\n", i)
|
||||
}
|
||||
case <-tout:
|
||||
fmt.Print("Done.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user