replace all import and gofmt code

This commit is contained in:
vcaesar 2019-02-19 10:34:55 -04:00
parent f0ddfd620c
commit 43543e0cff
4 changed files with 20 additions and 15 deletions

View File

@ -1,20 +1,18 @@
# gohook # gohook
[![CircleCI Status](https://circleci.com/gh/cauefcr/gohook.svg?style=shield)](https://circleci.com/gh/cauefcr/gohook) [![CircleCI Status](https://circleci.com/gh/robotn/gohook.svg?style=shield)](https://circleci.com/gh/robotn/gohook)
![Appveyor](https://ci.appveyor.com/api/projects/status/github/cauefcr/gohook?branch=master&svg=true) ![Appveyor](https://ci.appveyor.com/api/projects/status/github/robotn/gohook?branch=master&svg=true)
[![Go Report Card](https://goreportcard.com/badge/github.com/cauefcr/gohook)](https://goreportcard.com/report/github.com/cauefcr/gohook) [![Go Report Card](https://goreportcard.com/badge/github.com/robotn/gohook)](https://goreportcard.com/report/github.com/robotn/gohook)
[![GoDoc](https://godoc.org/github.com/cauefcr/gohook?status.svg)](https://godoc.org/github.com/cauefcr/gohook) [![GoDoc](https://godoc.org/github.com/robotn/gohook?status.svg)](https://godoc.org/github.com/robotn/gohook)
<!-- This is a work in progress. --> <!-- This is a work in progress. -->
Based on [libuiohook](https://github.com/kwhat/libuiohook)
```Go ```Go
package main package main
import ( import (
"fmt" "fmt"
//"github.com/robotn/gohook"
"github.com/cauefcr/gohook" "github.com/robotn/gohook"
) )
func main() { func main() {
@ -24,4 +22,6 @@ func main() {
fmt.Println(ev) fmt.Println(ev)
} }
} }
``` ```
Based on [libuiohook](https://github.com/kwhat/libuiohook).

2
go.mod
View File

@ -1 +1 @@
module github.com/cauefcr/gohook module github.com/robotn/gohook

View File

@ -151,3 +151,8 @@ func AddEvent(key string) int {
return geve return geve
} }
// StopEvent stop event listener
func StopEvent() {
C.stop_event()
}

View File

@ -4,13 +4,13 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/cauefcr/gohook" "github.com/robotn/gohook"
) )
func main() { func main() {
s := hook.Start() s := hook.Start()
defer hook.End() defer hook.End()
tout := time.After(time.Hour*2) tout := time.After(time.Hour * 2)
done := false done := false
for !done { for !done {
select { select {
@ -19,13 +19,13 @@ func main() {
if i.Keychar == 'q' { if i.Keychar == 'q' {
tout = time.After(0) 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 { } 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) //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) //fmt.Printf("x: %v, y: %v, button: %v, wheel: %v, rotation: %v\n", i.X, i.Y, i.Button,i.Amount,i.Rotation)
} else { } else {
fmt.Printf("%+v\n",i) fmt.Printf("%+v\n", i)
} }
case <-tout: case <-tout:
fmt.Print("Done.") fmt.Print("Done.")