2009-04-12 92 views
0

我對Vista的理解是,每個窗口都會獲得自己的屏幕緩衝區,然後通過alpha混合等來創建屏幕。在Vista中捕獲隱藏的窗口

那麼,有沒有什麼辦法可以截屏,其被遮擋或部分通過直接讀取這些緩衝區關閉屏幕的窗口?當您將鼠標懸停在任務欄上或將鼠標懸停在任務欄上時,Vista會執行此操作。

我在德爾福這樣做,但在任何語言的代碼就足夠了。

回答

2

我相信這些緩衝區時做這些窗口都關閉屏幕不存在。或者部分離屏時部分存在。

如果你留意窗口的縮略圖,你會發現,當這些窗口最小化或關閉屏幕也不會更新。 WM_PAINT將在窗口被從屏幕拖動到打開時觸發,這再次表明此數據尚未緩存在某處。

+0

的緩衝器是肯定有的,而被更新。開始播放視頻,用另一個窗口覆蓋它,將鼠標懸停在工具欄上,然後獲得播放視頻的縮略圖。 – 2009-04-12 12:40:55

0

下面是一些代碼,我寫了很久以前在C#中的屏幕捕獲應用程序。它使用Win32函數GetWindowRect得到你想要捕捉,創建與大小的位圖,然後使用Win32函數PrintWindow詢問窗口本身打印到該位圖的窗口的範圍:

RECT lRectangle = new RECT(); 
if (!GetWindowRect(lWindow.HWnd, ref lRectangle)) 
{ 
    MessageBox.Show(this, "An error occured while measuring the selected window.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); 
    return; 
} 

fCapturedImage = new Bitmap(lRectangle.Right - lRectangle.Left, lRectangle.Bottom - lRectangle.Top, PixelFormat.Format32bppArgb); 
using (Graphics lGraphics = Graphics.FromImage(fCapturedImage)) 
{ 
    HDC lHdc = lGraphics.GetHdc(); 
    PrintWindow(lWindow.HWnd, lHdc, 0); 
    lGraphics.ReleaseHdc(lHdc); 
} 
0

具有u considired掛鉤WM_PAINT消息有用嗎? 「Windows圖形編程:Win32 GDI和DirectDraw」的作者馮遠爲此提出了示例dll。我認爲用這種方式也可以捕獲DirectXed窗口(隨時都可以使用它)。 PLZ參考http://www.fengyuan.com/article/wmprint.html 你可以通過谷歌找到工作的delphi例子。也檢查expterts-exchange.com

0

我認爲可能是在新的DWM APi(桌面Windows管理器),讓你編寫和安裝自定義桌面管理器,訪問您看到在Flip3d和其他相同的縮略圖觀點。

0

做到這一點(C#)

public static Bitmap PrintWindow(IntPtr hwnd) 
    { 
     RECT rc; 
     WinUserApi.GetWindowRect(hwnd, out rc); 

     Bitmap bmp = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb); 
     Graphics gfxBmp = Graphics.FromImage(bmp); 
     IntPtr hdcBitmap = gfxBmp.GetHdc(); 
     bool succeeded = WinUserApi.PrintWindow(hwnd, hdcBitmap, 0); 
     gfxBmp.ReleaseHdc(hdcBitmap); 
     if (!succeeded) 
     { 
      gfxBmp.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(Point.Empty, bmp.Size)); 
     } 
     IntPtr hRgn = WinGdiApi.CreateRectRgn(0, 0, 0, 0); 
     WinUserApi.GetWindowRgn(hwnd, hRgn); 
     Region region = Region.FromHrgn(hRgn); 
     if (!region.IsEmpty(gfxBmp)) 
     { 
      gfxBmp.ExcludeClip(region); 
      gfxBmp.Clear(Color.Transparent); 
     } 
     gfxBmp.Dispose(); 
     return bmp; 
    }