public static void MainLoop() { PROCESS.SetWindowPos(0, 0, 800, 600); Thread.Sleep(200); foreach (var image in ImageList) { CvMat screen = Utils.TakeScreenshot().ToMat().ToCvMat(); Screenshot = new CvMat(screen.Rows, screen.Cols, MatrixType.U8C1); screen.CvtColor(Screenshot, ColorConversion.BgraToGray); Result = Cv.CreateImage(Cv.Size(Screenshot.Width - image.Width + 1, Screenshot.Height - image.Height + 1), BitDepth.F32, 1); Cv.MatchTemplate(Screenshot, image, Result, MatchTemplateMethod.CCoeffNormed); /*Screenshot.SaveImage("data/screenshot.png"); * image.SaveImage("data/image.png");*/ Cv.Normalize(Result, Result, 0, 1, NormType.MinMax); Cv.MinMaxLoc(Result, out MinAcc, out MaxAcc, out MinPos, out MaxPos, null); Console.WriteLine(MaxAcc); if (MaxAcc >= 0.75) { Position = new Point(MaxPos.X, MaxPos.Y); Utils.MoveMouse(Position); Thread.Sleep(15); Utils.LeftClick(); Thread.Sleep(100); MaxAcc = 0; } Result.Dispose(); } }
private void StartDrippin() { while (bActive) { //Utils.SetForegroundWindow(PROCESS.MainWindowHandle); foreach (var Image in ImageList) { for (int i = 0; i < 4; i++) { if (bActive) { CvMat Window = Utils.TakeScreenshot().ToMat().ToCvMat(); Screenshot = new CvMat(Window.Rows, Window.Cols, MatrixType.U8C1); Window.CvtColor(Screenshot, ColorConversion.BgraToGray); Result = Cv.CreateImage(Cv.Size(Screenshot.Width - Image.Width + 1, Screenshot.Height - Image.Height + 1), BitDepth.F32, 1); Cv.MatchTemplate(Screenshot, Image, Result, MatchTemplateMethod.CCoeffNormed); //Cv.Normalize(Result, Result, 0, 1, NormType.MinMax); Cv.MinMaxLoc(Result, out MinAcc, out MaxAcc, out MinPos, out MaxPos, null); if (MaxAcc >= 0.75) { Position = new Point(MaxPos.X + (Image.Width / 2), MaxPos.Y + (Image.Height / 2)); Utils.MoveMouse(Position); Thread.Sleep(15); Utils.LeftClick(); Thread.Sleep(100); MaxAcc = 0; } } } Result.Dispose(); } Thread.Sleep(2000); } }