我在某处找到了该代码,我发现它非常有用,但我想找到一种方法使其工作,以便它仅捕获给定的窗口目标。也许带有进程 ID 或窗口名称。即使该窗口未处于事件状态。
我不想使该窗口处于事件状态,但希望获得屏幕截图,就像我在其上执行 Alt+PrintScreen 一样。
这是适用于全屏捕获的代码
Private bmpScreenShot As Bitmap
Private gfxScreenshot As Graphics
bmpScreenShot = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb)
gfxScreenshot = Graphics.FromImage(bmpScreenShot)
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)
bmpScreenShot.Save(fileName, ImageFormat.Png)
我使用 Visual Basic 2008 Express
提前谢谢您!
最佳答案
看看这个Capture screenshot of active window?
您可以插入任何其他窗口的句柄,而不是 this.Handle
(当前窗口)(使用 WinAPI 函数,如 FindWindow
)
关于.net - VB.NET 窗口屏幕截图 (ALT+PRINTSCREEN),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2563381/