From b99914bc5ece12915e2a5eb61f973abe8b788bf3 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 9 Apr 2018 17:34:02 +0800 Subject: [PATCH] add find image by path --- robotgo.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/robotgo.go b/robotgo.go index b92775c..23564ee 100644 --- a/robotgo.go +++ b/robotgo.go @@ -809,6 +809,32 @@ func FindBitmap(args ...interface{}) (int, int) { return int(pos.x), int(pos.y) } +// FindPic finding the image by path +func FindPic(path string, args...interface{})(int, int){ + var ( + sbit C.MMBitmapRef + tolerance float64 + ) + + openbit := OpenBitmap(path) + + if len(args) > 0 { + sbit = args[0].(C.MMBitmapRef) + } else { + sbit = CaptureScreen() + } + + if len(args) > 1 { + tolerance = args[1].(float64) + } else { + tolerance = 0.5 + } + + fx, fy := FindBitmap(openbit, sbit, tolerance) + + return fx,fy +} + // FindEveryBitmap find the every bitmap func FindEveryBitmap(args ...interface{}) (int, int) { var (