Ejemplo n.º 1
0
 public override void activate()
 {
     if (clickType == 6)
     {
         MouseClicker.scrollMouse(x, y, delta);
     }
 }
Ejemplo n.º 2
0
 public override void activate()
 {
     if (clickType == 0)
     {
         MouseClicker.pressLeftMouse(x, y);
     }
     else if (clickType == 1)
     {
         MouseClicker.leaveLeftMouse(x, y);
     }
     else if (clickType == 2)
     {
         MouseClicker.pressRightMouse(x, y);
     }
     else if (clickType == 3)
     {
         MouseClicker.leaveRighttMouse(x, y);
     }
     else if (clickType == 4)
     {
         MouseClicker.pressMiddleMouse(x, y);
     }
     else if (clickType == 5)
     {
         MouseClicker.leaveMiddletMouse(x, y);
     }
 }
Ejemplo n.º 3
0
        public override void activate()
        {
            while (Form1.running) // check if still need to wait (user didn't press Escape to stop the macro)
            {
                Bitmap   imgAsBitmap     = TextDialog.ByteStringToBitmap(img);
                var      rc              = Screen.PrimaryScreen.Bounds;
                int      calScreenWidth  = rc.Width;
                int      calScreenHeight = rc.Height;
                Bitmap   bm              = new Bitmap(calScreenWidth, calScreenHeight);
                Graphics g          = Graphics.FromImage(bm);
                Mat      button_img = imgAsBitmap.ToMat();
                //get a scrennshot of the pc
                g.CopyFromScreen(0, 0, 0, 0, bm.Size);

                Mat    game_img = bm.ToMat();
                Mat    result   = new Mat();
                double minVal   = 0;
                double maxVal   = 0;
                Point  maxLoc   = new Point();
                Point  minLoc   = new Point();
                //search for matches and then take the highest
                CvInvoke.MatchTemplate(game_img, button_img, result, TemplateMatchingType.CcoeffNormed);
                CvInvoke.MinMaxLoc(result, ref minVal, ref maxVal, ref minLoc, ref maxLoc);

                if (maxVal > threshold)
                {
                    // before we exit we check if we need to click it
                    if (click)
                    {
                        switch (clickType)
                        {
                        case "Left Click":
                            //when we found, we click on the image (middle of the image)
                            MouseClicker.pressLeftMouse(maxLoc.X + x, maxLoc.Y + y);
                            MouseClicker.leaveLeftMouse(maxLoc.X + x, maxLoc.Y + y);
                            break;

                        case "Double Click":
                            //when we found, we click on the image (middle of the image)
                            MouseClicker.pressLeftMouse(maxLoc.X + x, maxLoc.Y + y);
                            MouseClicker.leaveLeftMouse(maxLoc.X + x, maxLoc.Y + y);
                            Thread.Sleep(100);
                            MouseClicker.pressLeftMouse(maxLoc.X + x, maxLoc.Y + y);
                            MouseClicker.leaveLeftMouse(maxLoc.X + x, maxLoc.Y + y);
                            break;

                        case "Right Click":
                            MouseClicker.pressRightMouse(maxLoc.X + x, maxLoc.Y + y);
                            MouseClicker.leaveRighttMouse(maxLoc.X + x, maxLoc.Y + y);
                            break;

                        case "Middle Click":
                            MouseClicker.pressMiddleMouse(maxLoc.X + x, maxLoc.Y + y);
                            MouseClicker.leaveMiddletMouse(maxLoc.X + x, maxLoc.Y + y);
                            break;

                        default:
                            break;
                        }
                    }
                    break;
                }
                game_img.Dispose();
                button_img.Dispose();
                result.Dispose();
                bm.Dispose();
                g.Dispose();
                new ManualResetEvent(false).WaitOne(1); // do sleep for 1 millisecond to not waste CPU (busy waiting)
            }
        }