简体   繁体   中英

C# Can I take screenshot of everything below active window

Is there any method / API allow calling something like CopyFromScreenAtDepth

I try to capture a preview of GUI below active window

then blur it to achieve something like Aero glass / OS X frosted glass blur effect

I have tried many workaround

  1. Set the Form opacity to 0 then capture and setting back to 1, this cause my form blinking.

  2. Make the Form background Blue with same transparent key, this will work at first time but GUI won't updating, so if I call this.Update() it will update the GUI, but cause blinking too.

My code:

private void MyForm_Load(object sender, EventArgs e) {
    Timer timer1 = new Timer();
    timer1.Tick += new EventHandler(UpdateBackground);
    timer1.Interval = 100; // in miliseconds
    timer1.Start();
}

private void UpdateBackground(object sender, EventArgs e)
{
    this.BackgroundImage = null;
    Bitmap myImage = new Bitmap(this.Width, this.Height);
    using (Graphics g = Graphics.FromImage(myImage))
    {
        this.Update();
        g.CopyFromScreen(new Point(this.Location.X, this.Location.Y), Point.Empty, new Size(this.Width, this.Height)); 
    }
    ImageTools.FastBlur(myImage, 4);
    this.BackgroundImage = myImage;
}

There is no such CopyFromScreenAtDepth() method call for Windows.

The best you can do is to use the Windows Magnification API for C++.
There are a TONs of drawback using it, like not having control over the Window position and size, limited capabilities, to none at all, at having both copy of screen below form and being able to have other controls, and the WOW64 problem when using a 32bits application with the API under 64bits OS...

I know it's an old question, but since it's a valid question with no answer so far, I thought it would be fair to answer it.
There are also other questions like this one around (which doesn't have answer either, and may be called duplicates...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM