예제 #1
0
파일: GetCursor.cs 프로젝트: Vas1123/bot
        public static Boolean IsCursorRed()
        {
            var cursorScreenShot = GetCursor.CaptureCursor();

            if (cursorScreenShot.GetPixel(1, 2).R > 180)
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
파일: Form1.cs 프로젝트: Vas1123/bot
        async void testFunction()
        {
            await Task.Run(() =>
            {
                Process[] process = Process.GetProcessesByName("rf_online.bin");
                Console.WriteLine(Environment.CurrentDirectory);

                System.Drawing.Bitmap monsterHPBarTempalte = new System.Drawing.Bitmap(@"..\..\..\Images\templateOfHealthBar.png");
                for (int i = 0; i < 100000; i++)
                {
                    var img1 = WorkWithImages.BringProcessToFrontAndCaptureGDIWindow(process);
                    Thread.Sleep(500); // Wait 0.5 sec to let mobs go to differnet place
                    var img2 = WorkWithImages.BringProcessToFrontAndCaptureGDIWindow(process);

                    var differenceAtImages = WorkWithImages.GetDiffInTwoImages(img1, img2);

                    var arrayOfCountours = WorkWithImages.FindCountoursAtImage(differenceAtImages);

                    var coordinatesForNewCursorPosition = WorkWithImages.GetBiggestCountourCoordinates(arrayOfCountours);
                    var gameWindowCoordinates           = NativeMethodsForWindow.GetAbsoluteClientRect(process[0].MainWindowHandle); // Find offset of the game dow

                    var x = coordinatesForNewCursorPosition.X + gameWindowCoordinates.X;
                    var y = coordinatesForNewCursorPosition.Y + gameWindowCoordinates.Y;

                    //Cursor.Position = new System.Drawing.Point(x, y);
                    Input.SmoothMouseMove(x, y, 0);

                    Thread.Sleep(900); // Waiting 'till cursor became red
                    if (GetCursor.IsCursorRed())
                    {
                        CharachterControl.TryToAttackMob();
                    }

                    if (WorkWithImages.IsImageMatchWithTemplate(Direct3DCapture.CaptureWindow(process[0].MainWindowHandle), monsterHPBarTempalte))
                    {
                        var counter = 0;
                        CharachterControl.AttackMobAndWait(1);
                        CharachterControl.PressKeyBoardButton(Convert.ToByte(Keys.F1)); // Press F1 to buff
                        try
                        {
                            while (WorkWithImages.IsImageMatchWithTemplate(Direct3DCapture.CaptureWindow(process[0].MainWindowHandle), monsterHPBarTempalte))
                            {
                                CharachterControl.AttackMobAndWait(1);
                                Thread.Sleep(1010);
                                counter++;
                                if ((counter % 6) == 0)
                                {
                                    CharachterControl.AttackMobAndWait(100);
                                    CharachterControl.PressKeyBoardButton(Convert.ToByte(Keys.F2)); // Press F2 to use skills
                                    CharachterControl.AttackMobAndWait(100);
                                }

                                if ((counter % 13) == 0)
                                {
                                    CharachterControl.AttackMobAndWait(100);
                                    CharachterControl.PressKeyBoardButton(Convert.ToByte(Keys.F1)); // Press F1 to buff
                                    CharachterControl.AttackMobAndWait(100);
                                }
                            }
                        }
                        finally
                        {
                            CharachterControl.GetLoot();
                            CharachterControl.PressKeyBoardButton(Convert.ToByte(Keys.Escape));
                        }
                    }
                }
            }
                           );
        }