Beispiel #1
0
        static String PrintWindow()
        {
            llc.Natives.RECT rect   = llc.Window.GetWindowBounds(llc.Window.GetForegroundWindow());
            Rectangle        bounds = new Rectangle
            {
                X      = rect.left,
                Y      = rect.top,
                Width  = rect.right - rect.left,
                Height = rect.bottom - rect.top
            };
            Bitmap bmp = new Bitmap(bounds.Width, bounds.Height);

            using (Graphics g = Graphics.FromImage(bmp))
                g.CopyFromScreen(bounds.Location, Point.Empty, bounds.Size);
            String name = GetScreenshotName();

            bmp.Save(name, ImageFormat.Png);
            return(name);
        }
Beispiel #2
0
        static String PrintScreen()
        {
            llc.Natives.RECT rect   = llc.Screen.GetScaledVirtualScreenRect();
            Rectangle        bounds = new Rectangle
            {
                X      = rect.left,
                Y      = rect.top,
                Width  = rect.right - rect.left,
                Height = rect.bottom - rect.top
            };
            Bitmap bmp = new Bitmap(bounds.Width, bounds.Height);

            using (Graphics g = Graphics.FromImage(bmp))
                g.CopyFromScreen(bounds.Location, Point.Empty, bounds.Size);
            // Since the program is single-threaded, race conditions won't happen
            // For multi-threaded program, use the following with try-catch can guarantee that no file is overwritten:
            // File.Open(path, FileMode.CreateNew)
            String name = GetScreenshotName();

            bmp.Save(name, ImageFormat.Png);
            return(name);
        }