diff --git a/bitmap/goBitmap.h b/bitmap/goBitmap.h index a728de4..503652e 100644 --- a/bitmap/goBitmap.h +++ b/bitmap/goBitmap.h @@ -117,6 +117,18 @@ MMPoint aFindBitmap(MMBitmapRef bit_map, MMRect rect){ return point; } +bool point_in_bounds(MMBitmapRef bitmap, MMPoint point){ + if (!bitmap_ready(bitmap)) { + return NULL; + } + + if (MMBitmapPointInBounds(bitmap, point)) { + return true; + } + + return false; +} + MMBitmapRef bitmap_open(char *path, uint16_t ttype){ // MMImageType type; @@ -146,7 +158,7 @@ char *bitmap_save(MMBitmapRef bitmap, char *path, uint16_t type){ if (saveMMBitmapToFile(bitmap, path, (MMImageType) type) != 0) { return "Could not save image to file."; } - //destroyMMBitmap(bitmap); + // destroyMMBitmap(bitmap); return "ok"; } diff --git a/robotgo.go b/robotgo.go index 9318d2a..f2c56ff 100644 --- a/robotgo.go +++ b/robotgo.go @@ -62,7 +62,7 @@ import ( ) const ( - version string = "v0.47.0.442, Mount Cook!" + version string = "v0.47.0.445, Mount Cook!" ) type ( @@ -165,7 +165,7 @@ func CaptureScreen(args ...int) C.MMBitmapRef { // fmt.Println("err:::", e) x = 0 y = 0 - //Get screen size. + // Get screen size. var displaySize C.MMSize displaySize = C.getMainDisplaySize() w = displaySize.width @@ -286,7 +286,7 @@ func SaveCapture(spath string, args ...int) { // MoveMouse move the mouse func MoveMouse(x, y int) { - //C.size_t int + // C.size_t int cx := C.size_t(x) cy := C.size_t(y) C.aMoveMouse(cx, cy) @@ -483,8 +483,8 @@ func KeyTap(args ...interface{}) { keyarr []string num int ) - // var ckeyarr []*C.char - ckeyarr := make([](*_Ctype_char), 0) + // var ckeyArr []*C.char + ckeyArr := make([](*_Ctype_char), 0) Try(func() { if reflect.TypeOf(args[1]) == reflect.TypeOf(keyarr) { @@ -494,7 +494,7 @@ func KeyTap(args ...interface{}) { num = len(keyarr) for i := 0; i < num; i++ { - ckeyarr = append(ckeyarr, (*C.char)(unsafe.Pointer(C.CString(keyarr[i])))) + ckeyArr = append(ckeyArr, (*C.char)(unsafe.Pointer(C.CString(keyarr[i])))) } } else { @@ -519,7 +519,7 @@ func KeyTap(args ...interface{}) { zkey := C.CString(args[0].(string)) if akey == "" && len(keyarr) != 0 { - C.aKey_Tap(zkey, (**_Ctype_char)(unsafe.Pointer(&ckeyarr[0])), C.int(num)) + C.aKey_Tap(zkey, (**_Ctype_char)(unsafe.Pointer(&ckeyArr[0])), C.int(num)) } else { // zkey := C.CString(args[0]) amod := C.CString(akey) @@ -547,18 +547,18 @@ func KeyToggle(args ...string) string { Try(func() { adown = args[1] - Try(func() { + if len(args) > 2 { amkey = args[2] + Try(func() { amkeyt = args[3] }, func(e interface{}) { // fmt.Println("err:::", e) amkeyt = "null" }) - }, func(e interface{}) { - // fmt.Println("err:::", e) + } else { amkey = "null" - }) + } }, func(e interface{}) { // fmt.Println("err:::", e) adown = "null" @@ -733,6 +733,16 @@ func FindBit(args ...interface{}) (int, int) { return int(pos.x), int(pos.y) } +// PointInBounds bitmap point in bounds +func PointInBounds(bitmap C.MMBitmapRef, x, y int) bool { + var point C.MMPoint + point.x = C.size_t(x) + point.y = C.size_t(y) + cbool := C.point_in_bounds(bitmap, point) + + return bool(cbool) +} + // OpenBitmap open the bitmap func OpenBitmap(args ...interface{}) C.MMBitmapRef { path := C.CString(args[0].(string)) diff --git a/vendor/vendor.json b/vendor/vendor.json index b774e46..2920321 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -65,8 +65,8 @@ { "checksumSHA1": "UuwHornIODuEq7fYnsZwdVgERLk=", "path": "github.com/shirou/gopsutil/mem", - "revision": "a8bc26299477e53c4ca89f7ec60160a74d4c0890", - "revisionTime": "2017-11-12T16:40:41Z" + "revision": "27389f01ec9364f60d6dba4fbe9751d3b7058d46", + "revisionTime": "2017-12-14T06:29:47Z" }, { "checksumSHA1": "AiC1wzY1Rjxs7iitVBvn4YM886k=",