Exemple #1
0
        public static void CheckMenu()
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);
            //Reset To Main Menu
            Main.ResetToHome();

            //Open Menu First
            MouseHandler.MoveCursor(LocationConstants.HOME_MENU_BUTTON, true);

            //Setting Up Boolean Var
            Boolean[] NotifAvailable = new Boolean[7];

            //Take New Screenshot
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            //Check If Anything on the menu needs to be completed (Keep In Mind Quests Needs a deeper Check)
            GlobalVariables.QUESTS_FINISHED = !PixelChecker.CheckPixelValue(LocationConstants.MENU_QUEST, ColorConstants.MENU_QUEST_RED); //Requires more checks

            //Events Require Two Checks
            if (PixelChecker.CheckPixelValue(LocationConstants.MENU_EVENTS, ColorConstants.MENU_EVENTS_GREEN) || PixelChecker.CheckPixelValue(LocationConstants.MENU_EVENTS, ColorConstants.MENU_EVENTS_RED))
            {
                GlobalVariables.EVENTS_COMPLETED = false;
            }


            GlobalVariables.HEARTS_SENT       = !PixelChecker.CheckPixelValue(LocationConstants.MENU_FRIENDS, ColorConstants.MENU_FRIENDS_RED);
            GlobalVariables.UPGRADED_FAMILIAR = !PixelChecker.CheckPixelValue(LocationConstants.MENU_FAMILIAR, ColorConstants.MENU_FAMILIAR_GREEN);
            GlobalVariables.MAIL_EMPTY        = !PixelChecker.CheckPixelValue(LocationConstants.MENU_MAILS, ColorConstants.MENU_MAIL_RED);

            Console.WriteLine(GlobalVariables.QUESTS_FINISHED);
            Console.WriteLine(GlobalVariables.EVENTS_COMPLETED);
            Console.WriteLine(GlobalVariables.HEARTS_SENT);
            Console.WriteLine(GlobalVariables.UPGRADED_FAMILIAR);
            Console.WriteLine(GlobalVariables.MAIL_EMPTY);
        }
Exemple #2
0
        public static async Task <String> DoAsync(System.Drawing.Point Location, System.Drawing.Size SizeOfRec, string OCREngine = "1")
        {
            Rectangle section = new Rectangle(Location, SizeOfRec);

            Bitmap ScreenCap     = WindowCapture.CaptureApplication("Nox");
            Bitmap ExtractedPart = new Bitmap(section.Width, section.Height);

            Graphics G = Graphics.FromImage(ExtractedPart);

            G.DrawImage(ScreenCap, 0, 0, section, GraphicsUnit.Pixel);

            string respones = string.Empty;

            string key = Functions.Authentication.LoginHandler.GetKey();

            try
            {
                HttpClient httpClient = new HttpClient();
                httpClient.Timeout = new TimeSpan(1, 1, 1);


                MultipartFormDataContent form = new MultipartFormDataContent();
                form.Add(new StringContent(key), "apikey"); //Added api key in form data // WHEN SERVER IS UP GET API KEY FROM SERVER
                form.Add(new StringContent("eng"), "language");
                form.Add(new StringContent(OCREngine), "OCREngine");

                ExtractedPart.Save("Image.png");
                byte[] imageData = File.ReadAllBytes("Image.png");

                //Make Sure To Enable this on Release
                //File.Delete("Image.png");

                form.Add(new ByteArrayContent(imageData, 0, imageData.Length), "image", "image.jpg");

                HttpResponseMessage response = await httpClient.PostAsync("https://api.ocr.space/Parse/Image", form);

                string strContent = await response.Content.ReadAsStringAsync();


                Rootobject ocrResult = JsonConvert.DeserializeObject <Rootobject>(strContent);

                if (ocrResult.OCRExitCode == 1)
                {
                    for (int i = 0; i < ocrResult.ParsedResults.Count(); i++)
                    {
                        respones += ocrResult.ParsedResults[i].ParsedText;
                    }
                }
                else
                {
                    Console.WriteLine("ERROR: " + strContent);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(respones);
        }
Exemple #3
0
        private void StartCapture()
        {
            StopCapture();

            WindowCapture = new WindowCapture(FindWindowTitle.Value, WindowCapture.Fps30);
            WindowCapture.Subscribe(OnNextBitmap, OnErrorBitmap, OnCompleteBitmap);
        }
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == User32.WM_HOTKEY)
     {
         if (Keys.Alt == Control.ModifierKeys)
         {
             initCapture(true);
         }
         else if (Keys.Control == Control.ModifierKeys)
         {
             CaptureImage(WindowCapture.CaptureWindow());
         }
         else if (Keys.Shift == Control.ModifierKeys)
         {
             if (!RuntimeConfig.LastCapturedRegion.Equals(Rectangle.Empty))
             {
                 CaptureRectangularArea(RuntimeConfig.LastCapturedRegion);
             }
         }
         else
         {
             initCapture();
         }
     }
     base.WndProc(ref m);
 }
        void OnMouseDown(object sender, MouseEventArgs e)
        {
            Down++;
            if (Down == 1 && MouseButtons.Left == e.Button)
            {
                HandleMouseDown();
            }
            else if (Down >= 1 && MouseButtons.Left == e.Button)
            {
                startMoving = true;
                Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();
                secStartX = tmpCursorLocation.X;
                secStartY = tmpCursorLocation.Y;
            }

            //if (e.Button == MouseButtons.Left &&!up)
            //{
            //    HandleMouseDown();
            //}
            //if (up == true)
            //{
            //    if (e.Button == MouseButtons.Left)
            //    {

            //        _twiceMouseDown = true;
            //        if (_twiceMouseDown == true )
            //        {
            //            _mX += 50;
            //            _mY += 50;
            //        }

            //      //  MessageBox.Show("true!");
            //    }
            //}
        }
        public void createGif(string filename, int durationMilliseconds = 5000, int msFrameDelay = 33, bool loop = false)
        {
            // 33 milliseconds for around 30 fps

            filename = filename.Replace("%desktop%", System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop));

            List <Image> images = new List <Image>();
            var          form   = MainController.Instance.WindowInstance;

            var temp = AnimatedGif.AnimatedGif.Create(filename, msFrameDelay, loop ? 0 : 1);

            while (durationMilliseconds > 0)
            {
                System.Threading.Thread.Sleep(msFrameDelay);
                durationMilliseconds -= msFrameDelay;

                form.Invoke(new Action(() => {
                    var img = WindowCapture.CaptureWindow(form.ChromeBrowserInstance.Handle);
                    images.Add(img);
                }));
            }

            foreach (var img in images)
            {
                temp.AddFrame(img);
            }

            temp.Dispose();
        }
 void CaptureRectangularArea(Rectangle rect)
 {
     CaptureImage(WindowCapture.CaptureWindow(User32.GetDesktopWindow(), rect));
     // save for re-capturing later and show recapture context menu option
     RuntimeConfig.LastCapturedRegion           = rect;
     this.contextmenu_capturelastregion.Enabled = true;
 }
Exemple #8
0
        public static void OpenPlanetTrial()
        {
            //No Need to call OpenCastle Since this is at top of castle

            //Get Attention of screen incase its not ontop
            WindowCapture.CaptureApplication("Nox");

            //Opening up Castle
            MouseHandler.MoveCursor(LocationConstants.HOME_BOTTOM_CASTLE_LOCATION, true);
            MouseHandler.MoveCursor(LocationConstants.CASTLE_SCROLL_LOCATION);
            Main.Sleep(2);

            //Scrolling to top of castle
            for (int i = 0; i < 8; i++)
            {
                MouseHandler.MouseWheelUp();
                Main.Sleep(1);
            }


            //Search Pixel Method is better than Specific location Since Expedition is an animation
            if (PixelChecker.SearchPixel(ColorConstants.CASTLE_PLANET_TRIAL_COLOR, out Point Location))
            {
                MouseHandler.MoveCursor(Location, true);
            }
            else
            {
                //TODO: Max 3 Retries before giving up
                OpenPlanetTrial();
            }
        }
Exemple #9
0
        public static void AttackBoss()
        {
            //Reset To Home
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);
            string BossStatus = ImageToText.HomeBoss();

            if (BossStatus == "next")
            {
                MouseHandler.MoveCursor(LocationConstants.HOME_BOSS_BATTLE_NEXT, true);
                Main.Sleep(2);
                MouseHandler.MoveCursor(LocationConstants.HOME_BOSS_IDLE_NEXT, true);
                Main.Sleep(1);
                AttackBoss(); //Starts Idling On Next Stage Then Re-Calls Function to Check for updates status
            }
            else if (BossStatus == "battle")
            {
                MouseHandler.MoveCursor(LocationConstants.HOME_BOSS_BATTLE_NEXT, true);
                Main.Sleep(2);
                MouseHandler.MoveCursor(LocationConstants.GLOBAL_ENEMYINFO_BATTLE_CONFIRM, true);
                Main.Sleep(2);
                MouseHandler.MoveCursor(LocationConstants.GLOBAL_TEAM_BATTLE_CONFIRM, true);
                Main.Sleep(3);

                MouseHandler.MoveCursor(LocationConstants.GLOBAL_BATTLE_SKIP, true);
                Main.Sleep(3);
                MouseHandler.MoveCursor(LocationConstants.GLOBAL_BATTLE_SKIP_CONFIRM, true);

                bool BattleFinished = false;

                while (!BattleFinished)
                {
                    //Sleep for 2 seconds and then Check
                    Main.Sleep(2);

                    if (PixelChecker.CheckPixelValue(LocationConstants.GLOBAL_BATTLE_FINISHED, ColorConstants.GLOBAL_BATTLE_FINISHED))
                    {
                        BattleFinished = true;
                    }
                }

                bool BattleWon = CheckWin();

                Console.WriteLine("The Outcome of the Battle Win: {0}", BattleWon);

                MouseHandler.MoveCursor(LocationConstants.GLOBAL_BATTLE_FINISHED, true);
            }

            ////Check if Button is Next Or Battle Boss
            //if (PixelChecker.CheckPixelValue(LocationConstants.HOME_BOSS_BATTLE_NEXT, ColorConstants.HOME_BOSS_BATTLE_COLOR))
            //{

            //}

            //Attack Boss
            MouseHandler.MoveCursor(LocationConstants.HOME_BOSS_BATTLE_NEXT, true);
        }
Exemple #10
0
        /// <summary>
        /// Takes a screencap of process and gets the pixel value of location
        /// </summary>
        /// <param name="PixelLocation"> Pixel X & Y that you want the value of </param>
        /// <returns> returns colour of pixel </returns>
        public static Color GetPixelColor(Point PixelLocation)
        {
            Bitmap bmp        = WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);
            Color  PixelValue = bmp.GetPixel(PixelLocation.X, PixelLocation.Y);

            return(PixelValue);
        }
Exemple #11
0
        private void InitCapture(CaptureType captureType)
        {
            try
            {
                base.SuspendLayout();
                base.Visible = false;
                base.Bounds  = Utils.GetScreenBounds();

#if DEBUG
                if (captureType == CaptureType.Region)
                {
                    System.Threading.Thread.Sleep(500);
                }
#endif

                // take screen shot of the the screens
                screenShot = WindowCapture.CaptureWindow();

                if (screenShot != null)
                {
                    pbCapture.Image = screenShot;

                    base.ResumeLayout(false);
                    base.Visible = true;
                    base.TopMost = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ColorToSearch"></param>
        /// <param name="Location"></param>
        /// <returns></returns>
        public static Boolean SearchPixel(Color ColorToSearch, out Point Location)
        {
            //Takes Screencap of NOX
            Bitmap ScreenCap = WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            //ScreenCap.Save("ScreenTest.bmp");

            Point ProcessLocation = WindowCapture.GetProcessPosition(GlobalVariables.GLOBAL_PROC_NAME);

            Location = new Point(0, 0);

            //Loops Through Each Pixel
            for (int x = 0; x < ScreenCap.Width; x++)
            {
                for (int y = 0; y < ScreenCap.Height; y++)
                {
                    Color currentPixelColor = ScreenCap.GetPixel(x, y);

                    if (ColorToSearch == currentPixelColor)
                    {
                        Location = new Point(x, y);
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #13
0
        public static void HomeBossAttackHandler(int retryAmount = 0)
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            HomeBossAttack(retryAmount);
        }
Exemple #14
0
        /// <summary>
        ///     The mouse move handler of the capture form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            var cursorLocation         = User32Api.GetCursorLocation();
            var relativeCursorPosition = WindowCapture.GetLocationRelativeToScreenBounds(cursorLocation);

            // Make sure the mouse coordinates are fixed, e.g. when pressing shift
            _mouseMovePos = FixMouseCoordinates(relativeCursorPosition);
        }
Exemple #15
0
    // Update is called once per frame
    void Update()
    {
        bool didChange;

        if (Time.time - lastUpdateTime < 1.0f / captureRateFps)
        {
            return;
        }
        else
        {
            lastUpdateTime = Time.time;
        }



        // Capture the desktop
        Texture2D desktopTexture = desktopCapture1.GetWindowTexture(out didChange);

        desktopObject.transform.localScale = new Vector3(desktopCapture1.desktopWidth * windowScale, 0.1f, desktopCapture1.desktopHeight * windowScale);
        if (didChange)
        {
            desktopObject.transform.GetComponent <Renderer>().material.mainTexture = desktopTexture;
        }

        // Gets information about position and icon of the cursor so you can render it onto the captured surfaces
        WindowCapture.UpdateCursorInfo();

        // Capture each window
        foreach (IntPtr key in windowsRendering.Keys)
        {
            WindowCapture window       = windowsRendering[key];
            GameObject    windowObject = windowObjects[key];

            if (windowObject == null)
            {
                continue;
            }

            Texture2D windowTexture = window.GetWindowTexture(out didChange);
            if (didChange)
            {
                windowObject.GetComponent <Renderer>().material.mainTexture = windowTexture;
            }
            windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
        }

        // Poll for new windows
        if (Time.time - lastPollWindowsTime < 1.0f / windowPollPerSecond)
        {
            return;
        }
        else
        {
            lastPollWindowsTime = Time.time;
            // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
            captureManager.Poll();
        }
    }
Exemple #16
0
        /* Might Be Wondering why i have a seperate function which "Handles" the
         * Attack when i could just add the commands to the main function
         * but the reason is because i can call it to reset / reopen
         * the Attack Object when something goes wrong.
         */

        #region DenOfSecrets Attack
        public static void DenOfSecretAttackHandler()
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            OpenObjects.OpenDoS();

            AttackDenOfSecrets();
        }
Exemple #17
0
        public static void PlanetTrialAttackHandler()
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            OpenObjects.OpenPlanetTrial();

            PlanetTrialAttack();
        }
Exemple #18
0
        public static void BattleLeagueAttackHandler()
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            OpenObjects.OpenBattleLeague();

            AttackBattleLeague();
        }
Exemple #19
0
        /* Might Be Wondering why i have a seperate function which "Handles" the
         * Attack when i could just add the commands to the main function
         * but the reason is because i can call it to reset / reopen
         * the Attack Object when something goes wrong.
         */

        public static void SkyPillarAttackHandler()
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            OpenObjects.OpenSkyPilar();

            AttackSkyPillar();
        }
Exemple #20
0
        /// <summary>
        /// Calculate the zoom size
        /// </summary>
        /// <param name="screenBounds">NativeRect with the screenbounds</param>
        /// <returns>NativeSize</returns>
        private NativeSize CalculateZoomSize(NativeRect screenBounds)
        {
            // convert to be relative to top left corner of all screen bounds
            screenBounds = screenBounds.MoveTo(WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location));
            var relativeZoomSize = Math.Min(screenBounds.Width, screenBounds.Height) / 5;

            // Make sure the final size is a plural of 4, this makes it look better
            relativeZoomSize = relativeZoomSize - relativeZoomSize % 4;
            return(new NativeSize(relativeZoomSize, relativeZoomSize));
        }
Exemple #21
0
 public DolphinWindowCapture()
 {
     Process[] p = Process.GetProcessesByName("Dolphin");
     if (p.Length <= 0)
     {
         throw new CouldNotFindDolphinWindowException();
     }
     mainWindowHandle = p[0].MainWindowHandle;
     capture          = new WindowCapture();
 }
Exemple #22
0
        /// <summary>
        ///     This is called when we start selecting a region
        /// </summary>
        private void StartSelecting()
        {
            var tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();

            _mX        = tmpCursorLocation.X;
            _mY        = tmpCursorLocation.Y;
            _mouseDown = true;
            OnMouseMove(this, null);
            Invalidate();
        }
Exemple #23
0
        public static bool BraveAttackHandler()
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            OpenObjects.OpenArena();

            return(AttackBraveLeague());
        }
        private void HandleMouseDown()
        {
            Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();

            _mX        = tmpCursorLocation.X;
            _mY        = tmpCursorLocation.Y;
            _mouseDown = true;
            OnMouseMove(this, null);
            Invalidate();
        }
Exemple #25
0
    // Update is called once per frame
    void Update()
    {
        bool didChange;

        // Capture each window
        foreach (IntPtr key in windowsRendering.Keys)
        {
            WindowCapture window       = windowsRendering[key];
            GameObject    windowObject = windowObjects[key];

            if (windowObject == null)
            {
                continue;
            }

            windowTexture = window.GetWindowTexture(out didChange);
            if (didChange)
            {
                //windowObject.GetComponent<Renderer>().material.mainTexture = windowTexture;
                foreach (Material mat in mats)
                {
                    mat.mainTexture = windowTexture;
                }
            }
            windowTexture = null;
            //windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
        }

        // Poll for new windows
        if (windowFound == false)
        {
            if (count >= 5)
            {
                windowFound = true;
            }
            if (Time.time - lastPollWindowsTime < 1.0f / windowPollPerSecond)
            {
                return;
            }
            else
            {
                count++;
                lastPollWindowsTime = Time.time;
                // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
                captureManager.Poll();
            }
        }
        if (!actualWindowFound)
        {
            foreach (Material mat in mats)
            {
                mat.mainTexture = noSignalTex;
            }
        }
    }
        /// <summary>
        /// This creates the capture form
        /// </summary>
        /// <param name="capture"></param>
        /// <param name="windows"></param>
        public CaptureForm(ICapture capture, List <WindowDetails> windows)
        {
            if (_currentForm != null)
            {
                LOG.Debug("Found currentForm, Closing already opened CaptureForm");
                _currentForm.Close();
                _currentForm = null;
                Application.DoEvents();
            }
            _currentForm = this;

            // Enable the AnimatingForm
            EnableAnimation = true;

            // clean up
            FormClosed += ClosedHandler;

            _capture     = capture;
            _windows     = windows;
            _captureMode = capture.CaptureDetails.CaptureMode;

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            // Only double-buffer when we are not in a TerminalServerSession
            DoubleBuffered = !isTerminalServerSession;
            Text           = "Greenshot capture form";

            // Make sure we never capture the captureform
            WindowDetails.RegisterIgnoreHandle(Handle);
            // Unregister at close
            FormClosing += ClosingHandler;

            // set cursor location
            _cursorPos = WindowCapture.GetCursorLocationRelativeToScreenBounds();

            // Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
            if (_captureMode == CaptureMode.Window)
            {
                _windowAnimator = new RectangleAnimator(new Rectangle(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
            }

            // Set the zoomer animation
            InitializeZoomer(Conf.ZoomerEnabled);

            SuspendLayout();
            Bounds = capture.ScreenBounds;
            ResumeLayout();

            // Fix missing focus
            WindowDetails.ToForeground(Handle);
            TopMost = true;
        }
Exemple #27
0
 void OnRemoveWindow(WindowCapture window)
 {
     Debug.Log("removed " + window.windowInfo.title);
     if (windowsRendering.ContainsKey(window.hwnd))
     {
         GameObject windowObjectRemoving = windowObjects[window.hwnd];
         Destroy(windowObjectRemoving);
         windowObjects.Remove(window.hwnd);
         windowsRendering.Remove(window.hwnd);
     }
 }
Exemple #28
0
 /// <summary>
 /// The mousedown handler of the capture form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();
         mX        = tmpCursorLocation.X;
         mY        = tmpCursorLocation.Y;
         mouseDown = true;
         OnMouseMove(this, e);
         Invalidate();
     }
 }
Exemple #29
0
 void OnAddWindow(WindowCapture window)
 {
     if (!windowsRendering.ContainsKey(window.hwnd) && IsGoodWindow(window))
     {
         GameObject windowObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
         windowObject.name = window.windowInfo.title;
         windowObject.transform.GetComponent <Renderer>().material = new Material(windowShader);
         windowObject.transform.localEulerAngles = new Vector3(90, 0, 0);
         windowsRendering[window.hwnd]           = window;
         windowObjects[window.hwnd] = windowObject;
     }
 }
Exemple #30
0
        public static void OpenGuild()
        {
            WindowCapture.CaptureApplication(GlobalVariables.GLOBAL_PROC_NAME);

            Main.ResetToHome();

            Main.Sleep(2);

            MouseHandler.MoveCursor(LocationConstants.HOME_BOTTOM_GUILD, true);

            Main.Sleep(2);
        }