-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouse.go
More file actions
38 lines (30 loc) · 735 Bytes
/
mouse.go
File metadata and controls
38 lines (30 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// +build darwin
package userinput
// #cgo CFLAGS: -x objective-c
// #cgo LDFLAGS: -framework Cocoa
// #include <AppKit/NSEvent.h>
//
// NSPoint mouseLocation(){
// return [NSEvent mouseLocation];
// }
import "C"
//NSPoint
type Point struct {
X float64
Y float64
}
func MouseClick( x float64, y float64 ){
}
func MouseMove( x float64, y float64 ){
var move = C.CGEventCreateMouseEvent(
nil,
C.kCGEventMouseMoved,
C.CGPointMake(C.CGFloat(x),C.CGFloat(y)),
0)
// defer C.CFRelease( move )
C.CGEventPost(C.kCGHIDEventTap, move)
}
func MousePosition() Point {
var event = C.mouseLocation()
return Point{ X: float64(event.x), Y: float64(event.y) }
}