Closed rajkumarks7 closed 4 years ago
What's your code?
I can share you somepart of code
Package main func main() {
go Mousecount()
}
func Mousecount() {
for {
EvChan := hook.Start()
defer hook.End()
var j uint16
b := 0
start:=time.now()
for ev := range EvChan {
fmt.Sprint("hook: ", ev)
j = j + ev.Clicks
if ev.Rawcode >= 1 {
b++
}
if time.Since(start) > time.Second*59 {
break
}
}
fmt.Println(j / 4)
fmt.Println(b / 4)
time.Sleep(500 * time.Millisecond)
}
}
Have you tried putting select{}
after go Mousecount()
(to pause until kill/TERM). Your program will exit instantly otherwise
No I did not can you tell me where do I use it ? In my code I do have other go routines
Have you tried putting
select{}
aftergo Mousecount()
(to pause until kill/TERM). Your program will exit instantly otherwise
i used like this func main(){ go Screenshots() go mousecount() select{} } but i am still getting this error
Have you tried obtaining the event channel and then passing it to both?
No I did not can you tell me how to do it ?
Do:
EvChan := hook.Start()
defer hook.End()
in main()
.
Modify the functions to take a chan hook.Event
as a parameter. Then range
over that parameter
Okay I should try with it then thank you
Do:
EvChan := hook.Start() defer hook.End()
in
main()
.Modify the functions to take a
chan hook.Event
as a parameter. Thenrange
over that parameter
hey can you show me once i am not getting it
I am using ubuntu 18.04 and go version 1.14 and gohook version v 0.30.3
fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7fc83fc0f215]
runtime stack: runtime.throw(0xdf06d7, 0x2a) /usr/local/go/src/runtime/panic.go:1116 +0x72 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:679 +0x46a
goroutine 1498 [syscall, 1 minutes]: runtime.cgocall(0xbeb450, 0xc001da47e0, 0xb26f74) /usr/local/go/src/runtime/cgocall.go:133 +0x5b fp=0xc001da47b0 sp=0xc001da4778 pc=0x4386db github.com/robotn/gohook._Cfunc_start_ev() _cgo_gotypes.go:124 +0x41 fp=0xc001da47e0 sp=0xc001da47b0 pc=0xb259b1 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc001da47e8 sp=0xc001da47e0 pc=0x498281 created by github.com/robotn/gohook.Start /home/karthik/go/pkg/mod/github.com/robotn/gohook@v0.30.3/hook.go:224 +0x67