gohook/hook.go

47 lines
1.1 KiB
Go

// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
package hook
/*
#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations
#cgo darwin LDFLAGS: -framework Cocoa
#cgo linux CFLAGS:-I/usr/src
#cgo linux LDFLAGS: -L/usr/src -lX11 -lXtst
#cgo linux LDFLAGS: -lX11-xcb -lxcb -lxcb-xkb -lxkbcommon -lxkbcommon-x11
//#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)
defer C.free(unsafe.Pointer(cs))
eve := C.add_event(cs)
geve := int(eve)
return geve
}
// StopEvent stop event listener
func StopEvent() {
C.stop_event()
}