gohook/hook.go

35 lines
664 B
Go
Raw Normal View History

2018-09-17 07:29:13 +08:00
package hook
/*
#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations
#cgo darwin LDFLAGS: -framework Cocoa
#cgo linux CFLAGS:-I/usr/src
2018-09-17 07:43:30 +08:00
#cgo linux LDFLAGS: -L/usr/src -lX11 -lXtst
#cgo linux LDFLAGS: -lX11-xcb -lxcb -lxcb-xkb -lxkbcommon -lxkbcommon-x11
2018-09-17 07:29:13 +08:00
#cgo windows LDFLAGS: -lgdi32 -luser32
#include "event/goEvent.h"
// #include "event/hook_async.h"
*/
import "C"
import(
// "fmt"
"unsafe"
)
// AddEvent add event listener
func AddEvent(key string) int {
cs := C.CString(key)
2018-09-17 08:17:40 +08:00
defer C.free(unsafe.Pointer(cs))
2018-09-17 07:29:13 +08:00
eve := C.add_event(cs)
geve := int(eve)
return geve
}
// StopEvent stop event listener
func StopEvent() {
C.stop_event()
}