robotn / gohook

GoHook, Go global keyboard and mouse listener hook
MIT License
324 stars 43 forks source link

Made the library Asyncronous #2

Closed cauefcr closed 5 years ago

cauefcr commented 5 years ago

I added two channels to the project, a Go one and a C one (eb_chan), the C one is accessed from the dispatch_process, where the events are sent in json form, the second one is accessible to the user, is used by the pollEv function. pollEv reads from the C channel, converts the json to the Event struct and sends it to the Go channel.

The project only has two functions now: Start and End, which attaches and detaches the hook, as well as manage the global state, respectively.

(hope the PR is accepted :) )

cauefcr commented 5 years ago

What do you think about adding routing support, so the library user can do something like:

hook.Pressed("/kbd/a",func(e){
    fmt.Print("a was pressed")
})
vcaesar commented 5 years ago

The code has been tested on one platform, and will be further reviewed and tested on other platforms to merge.

vcaesar commented 5 years ago

Thanks, this is awesome work.

cauefcr commented 5 years ago

You're quite welcome, thanks for robotgo.