屏幕捕获类






4.25/5 (9投票s)
SCapture 类允许应用程序捕获静态屏幕图像
引言
SCapture
类允许应用程序捕获静态屏幕图像。它还提供了一个功能,可以将光标包含在图像中。
类共享方法
FullScreen
- 捕获全屏(所有监视器在一个图像中)DisplayMonitor
- 捕获显示器ActiveWindow
- 捕获活动窗口Window
- 捕获由句柄指定的窗口(重载)Control
- 捕获由句柄或点指定的窗口的控件(重载)ScreenRectangle
- 从屏幕捕获矩形图像
背景
该类与其他提供从屏幕捕获图像的类的不同之处在于,它赋予应用程序捕获透明 Windows 图像的能力。该类核心基于一些 API 方法。
Using the Code
一个小示例,通过使用按钮上的一个点来捕获表单上的按钮控件图像。
Private Sub ControlButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ControlButton.Click
Try
'Capture the image of this button including the cursor.
Dim img As Image = SCapture.Control(Control.MousePosition, True)
'Save the captured image.
img.Save(filePath, Drawing.Imaging.ImageFormat.Png)
'Also display the captured image in a PictureBox.
Me.DisplayPictureBox.Image = img
Catch ex As Exception
'Show a MessageBox if the capture of image failed.
MessageBox.Show("Failed to capture the control!" _
& Environment.NewLine & ex.Message, "Capture Error!", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
历史
- 最初发布于 2008年7月21日
- 于 2008年8月5日更新
- 添加了一个可重载的 Window 方法,该方法将一个点作为其参数之一,并返回该点处窗口的
bitmap
- 将所有捕获方法的返回类型从
Image
更改为Bitmap
- 添加了一个可重载的 Window 方法,该方法将一个点作为其参数之一,并返回该点处窗口的