Beispiel #1
0
        private void RecordUsingCache()
        {
            try
            {
                for (int i = 0; !stopRequested && (frameCount == 0 || i < frameCount); i++)
                {
                    Stopwatch timer = Stopwatch.StartNew();

                    Image img = screenshot.CaptureRectangle(CaptureRectangle);
                    //DebugHelper.WriteLine("Screen capture: " + (int)timer.ElapsedMilliseconds);

                    imgCache.AddImageAsync(img);

                    if (!stopRequested && (frameCount == 0 || i + 1 < frameCount))
                    {
                        int sleepTime = delay - (int)timer.ElapsedMilliseconds;

                        if (sleepTime > 0)
                        {
                            Thread.Sleep(sleepTime);
                        }
                        else if (sleepTime < 0)
                        {
                            // Need to handle FPS drops
                        }
                    }
                }
            }
            finally
            {
                imgCache.Finish();
            }
        }
        public Image GetAreaImage(Screenshot screenshot)
        {
            Rectangle rect = SelectionRectangle0Based;

            if (rect.Width > 0 && rect.Height > 0)
            {
                return(screenshot.CaptureRectangle(SelectionRectangle));
            }

            return(null);
        }
Beispiel #3
0
        private void captureTimer_Tick(object sender, EventArgs e)
        {
            if (firstCapture)
            {
                firstCapture          = false;
                captureTimer.Interval = Options.ScrollDelay;

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.KeyPressHome)
                {
                    InputHelpers.SendKeyPress(VirtualKeyCode.HOME);
                }

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.SendMessageTop)
                {
                    NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_TOP, 0);
                }

                if (Options.ScrollTopMethodBeforeCapture != ScrollingCaptureScrollTopMethod.None)
                {
                    return;
                }
            }

            Screenshot screenshot = new Screenshot()
            {
                CaptureCursor = false
            };
            Bitmap bmp = screenshot.CaptureRectangle(selectedRectangle);

            if (bmp != null)
            {
                images.Add(bmp);
            }

            if (Options.ScrollMethod == ScrollingCaptureScrollMethod.Automatic && detectingScrollMethod && images.Count > 1 && IsLastTwoImagesSame())
            {
                if (currentScrollMethod == ScrollingCaptureScrollMethod.SendMessageScroll)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.KeyPressPageDown;
                }
                else if (currentScrollMethod == ScrollingCaptureScrollMethod.KeyPressPageDown)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.MouseWheel;
                }
                else
                {
                    StopCapture();
                }
            }
            else if (currentScrollCount == Options.MaximumScrollCount || (Options.AutoDetectScrollEnd && IsScrollReachedBottom(selectedWindow.Handle)))
            {
                StopCapture();
            }
            else if (images.Count > 1)
            {
                detectingScrollMethod = false;
            }

            switch (currentScrollMethod)
            {
            case ScrollingCaptureScrollMethod.Automatic:
            case ScrollingCaptureScrollMethod.SendMessageScroll:
                NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_PAGEDOWN, 0);
                break;

            case ScrollingCaptureScrollMethod.KeyPressPageDown:
                InputHelpers.SendKeyPress(VirtualKeyCode.NEXT);
                break;

            case ScrollingCaptureScrollMethod.MouseWheel:
                InputHelpers.SendMouseWheel(-120);
                break;
            }

            currentScrollCount++;
        }
        public Image GetAreaImage(Screenshot screenshot)
        {
            Rectangle rect = SelectionRectangle0Based;

            if (rect.Width > 0 && rect.Height > 0)
            {
                return screenshot.CaptureRectangle(SelectionRectangle);
            }

            return null;
        }
Beispiel #5
0
        private void captureTimer_Tick(object sender, EventArgs e)
        {
            if (firstCapture)
            {
                firstCapture = false;
                captureTimer.Interval = Options.ScrollDelay;

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.KeyPressHome)
                {
                    InputHelpers.SendKeyPress(VirtualKeyCode.HOME);
                }

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.SendMessageTop)
                {
                    NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_TOP, 0);
                }

                if (Options.ScrollTopMethodBeforeCapture != ScrollingCaptureScrollTopMethod.None)
                {
                    return;
                }
            }

            Screenshot screenshot = new Screenshot() { CaptureCursor = false };
            Image image = screenshot.CaptureRectangle(selectedRectangle);

            if (image != null)
            {
                images.Add(image);
            }

            if (Options.ScrollMethod == ScrollingCaptureScrollMethod.Automatic && detectingScrollMethod && images.Count > 1 && IsLastTwoImagesSame())
            {
                if (currentScrollMethod == ScrollingCaptureScrollMethod.SendMessageScroll)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.KeyPressPageDown;
                }
                else if (currentScrollMethod == ScrollingCaptureScrollMethod.KeyPressPageDown)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.MouseWheel;
                }
                else
                {
                    StopCapture();
                }
            }
            else if (currentScrollCount == Options.MaximumScrollCount || (Options.AutoDetectScrollEnd && IsScrollReachedBottom(selectedWindow.Handle)))
            {
                StopCapture();
            }
            else if (images.Count > 1)
            {
                detectingScrollMethod = false;
            }

            switch (currentScrollMethod)
            {
                case ScrollingCaptureScrollMethod.Automatic:
                case ScrollingCaptureScrollMethod.SendMessageScroll:
                    NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_PAGEDOWN, 0);
                    break;
                case ScrollingCaptureScrollMethod.KeyPressPageDown:
                    InputHelpers.SendKeyPress(VirtualKeyCode.NEXT);
                    break;
                case ScrollingCaptureScrollMethod.MouseWheel:
                    InputHelpers.SendMouseWheel(-120);
                    break;
            }

            currentScrollCount++;
        }