Ejemplo n.º 1
0
        /// <summary>
        /// Captures a specific area from the screen
        /// </summary>
        public static Bitmap CaptureArea(Rectangle rectangle)
        {
            var width    = rectangle.Width.ToInt();
            var height   = rectangle.Height.ToInt();
            var bmp      = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            var graphics = Graphics.FromImage(bmp);

            graphics.CopyFromScreen(rectangle.Left.ToInt(), rectangle.Top.ToInt(), 0, 0, new System.Drawing.Size(width, height), CopyPixelOperation.SourceCopy);
            return(bmp);
        }
Ejemplo n.º 2
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            try
            {
                FlaUI.Core.Shapes.Point pt1 = FlaUI.Core.Input.Mouse.Position;
                AutomationElement       e1  = automation.FromPoint(pt1);
                if (e1.Properties.ProcessId == Process.GetCurrentProcess().Id)
                {
                    return;
                }

                e1.DrawHighlight(false, System.Windows.Media.Colors.Blue, TimeSpan.FromMilliseconds(500));
                if (e1 != LastElement)
                {
                    LastElement = e1;
                    LastXPath   = GetXPath(e1);
                    LastRect    = e1.BoundingRectangle;
                }
            }
            catch (Exception)
            { }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Captures a specific area and saves it to a file
        /// </summary>
        public static void CaptureAreaToFile(Rectangle rectangle, string filePath)
        {
            var bmp = CaptureArea(rectangle);

            bmp.Save(filePath, ImageFormat.Png);
        }
Ejemplo n.º 4
0
 public static BitmapImage CaptureAreaWpf(Rectangle rectangle)
 {
     return(CaptureArea(rectangle).ToWpf());
 }