mirror of
https://github.com/robotn/gohook.git
synced 2024-11-11 02:16:40 +08:00
add example and update code style
This commit is contained in:
parent
1da30b1d41
commit
9fa8b6c408
@ -18,6 +18,7 @@ import (
|
||||
func main() {
|
||||
EvChan := hook.Start()
|
||||
defer hook.End()
|
||||
|
||||
for ev := range EvChan {
|
||||
fmt.Println(ev)
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ environment:
|
||||
PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH%
|
||||
# - COMPILER: MINGW_W64
|
||||
# ARCHITECTURE: x64
|
||||
GOVERSION: 1.11.4
|
||||
GOVERSION: 1.11.5
|
||||
# GOPATH: c:\gopath
|
||||
|
||||
# scripts that run after cloning repository
|
||||
|
@ -34,7 +34,9 @@ void pollEv(){
|
||||
if (events == NULL) return;
|
||||
for (;eb_chan_buf_len(events)!=0;) {
|
||||
char* tmp;
|
||||
if( eb_chan_try_recv(events,(const void**) &tmp) == eb_chan_res_ok ){
|
||||
if (eb_chan_try_recv(events, (const void**) &tmp)
|
||||
== eb_chan_res_ok) {
|
||||
// send a char
|
||||
go_send(tmp);
|
||||
free(tmp);
|
||||
} else {
|
||||
|
40
example/main.go
Normal file
40
example/main.go
Normal file
@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/robotn/gohook"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func base() {
|
||||
EvChan := hook.Start()
|
||||
defer hook.End()
|
||||
|
||||
for ev := range EvChan {
|
||||
fmt.Println(ev)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
base()
|
||||
|
||||
add()
|
||||
}
|
@ -175,6 +175,7 @@ var (
|
||||
251: "unlock trackpad (Chrome/Edge)",
|
||||
255: "toggle touchpad",
|
||||
}
|
||||
|
||||
keytoraw = map[string]uint16{
|
||||
"error": 0,
|
||||
"break": 3,
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
func main() {
|
||||
s := hook.Start()
|
||||
defer hook.End()
|
||||
|
||||
tout := time.After(time.Hour * 2)
|
||||
done := false
|
||||
for !done {
|
||||
@ -19,6 +20,7 @@ func main() {
|
||||
if i.Keychar == 'q' {
|
||||
tout = time.After(0)
|
||||
}
|
||||
|
||||
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)
|
||||
@ -27,6 +29,7 @@ func main() {
|
||||
} else {
|
||||
fmt.Printf("%+v\n", i)
|
||||
}
|
||||
|
||||
case <-tout:
|
||||
fmt.Print("Done.")
|
||||
done = true
|
||||
|
Loading…
Reference in New Issue
Block a user