Vb.net PRTSC (Screen capture) - Error
Hi again my question this time its related with this piece of code, im using the visual studio beta 2012, i cant seem to find the issue, if you guys could help me out ill appreciate it
Public Class Form1
Private Sub fullScreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fullScreen.Click
SendKeys.SendWait("^{PRTSC}")
Dim clip As IDataObject = Clipboard.GetDataObject()
If clip.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
Dim screenCapture As Bitmap = CType(clip.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
screenCapture.Save("C:\fullScreenCapture.bmp")
End If
Clipboard.Clear()
End Sub
End Class
Ошибка:
A first chance exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
Дополнительная информация: Ошибка genérico en GDI+.
Если есть обработчик для этого исключения, программа может быть безопасно продолжена.
2 ответа
Решение
Вы можете сделать снимок экрана более легко, используя следующее (по моему опыту, клавиши отправки всегда ударили и пропустили)
Private Function TakeScreenShot() As Bitmap
Dim scrn As Screen = Screen.FromControl(Me)
Dim screenSize As Size = New Size(scrn.Bounds.Width, scrn.Bounds.Height)
Dim screenGrab As New Bitmap(screenSize.Width, screenSize.Height)
Dim g As Graphics = Graphics.FromImage(screenGrab)
g.CopyFromScreen(New Point(scrn.Bounds.X, scrn.Bounds.Y), New Point(0, 0), screenSize)
Return screenGrab
End Function
Вы пытаетесь захватить экран? Почему бы не использовать классы VS для захвата экрана?
http://forum.codecall.net/topic/51761-creating-a-screen-shot-tool-vbnet/