目前我有以下 VB.NET 代码来制作我的桌面截图,但它只拍摄活动屏幕的图片:
Public Function SaveScreen(ByVal theFile As String) As Boolean
Try
SendKeys.Send("%{PRTSC}") '<alt + printscreen>
Application.DoEvents()
Dim data As IDataObject = Clipboard.GetDataObject()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
Dim bmp As Bitmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
bmp.Save(theFile, Imaging.ImageFormat.Png)
End If
Clipboard.SetDataObject(0) 'save memory by removing the image from the clipboard
Return True
Catch ex As Exception
Return False
End Try
End Function
以下代码是我执行上述函数的方式,如果它有任何区别,我认为它不会:
SaveScreen("C:\Lexer_trace\screen.png")
现在,我需要能够拍摄整个屏幕的照片,而不仅仅是聚焦的窗口。我该怎么做?
提前致谢,
洛根