mirror of
https://github.com/robotn/gohook.git
synced 2025-04-29 00:07:39 +08:00
- New event struct mimiking C structs - changed c channel library to eb_chan - changed API to something more palatable
30 lines
390 B
Go
30 lines
390 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/cauefcr/gohook"
|
|
)
|
|
|
|
func main() {
|
|
s := hook.Start()
|
|
tout := time.After(time.Second * 10)
|
|
done := false
|
|
for !done {
|
|
select {
|
|
case i := <-s:
|
|
if i.Keychar == uint16('q') {
|
|
tout = time.After(1 * time.Millisecond)
|
|
}
|
|
fmt.Printf("%+v\n", i)
|
|
case <-tout:
|
|
fmt.Print("Done.")
|
|
done = true
|
|
break;
|
|
}
|
|
}
|
|
hook.End()
|
|
|
|
}
|