How can I take a screen shot in VB.NET?
Printable View
How can I take a screen shot in VB.NET?
PRINTSCREEN :D
VB Code:
Public Function GetScreenCapture( _ Optional ByVal FullScreen As Boolean = False) As Image ' Captures the current screen and returns as an Image ' object Dim objSK As SendKeys Dim imgCapture As Image If FullScreen = True Then ' Print Screen pressed twice here as some systems ' grab active window "accidentally" on first run objSK.SendWait("{PRTSC 2}") Else objSK.SendWait("%{PRTSC}") End If Dim objData As IDataObject = Clipboard.GetDataObject() Return objData.GetData(DataFormats.Bitmap) End Function 'USAGE GetScreenCapture(True).Save("c:\screengrab.bmp") PictureBox1.Image = GetScreenCapture()
What does this symbol mean (%) ???
It did it !
thanx for your help
... or use SnagIt! :pQuote:
Originally posted by Pirate
How can I take a screen shot in VB.NET?
:D no I just need to include this feature into my proj!;)
That's used to make an screenshot from the current window... it's the same when u press ALT+PRINTSCREENQuote:
Originally posted by Pirate
What does this symbol mean (%) ???
As I got this , it's like a shortcut key .If so , that would be great because I wanted to create a shortcut key !
umm any better way besides pressing the print key?
shortcut keys !
I mean hotkeys
oh hotkeysQuote:
Originally posted by Pirate
I mean hotkeys
what about them
It's another way than Print keyQuote:
Originally posted by MrPolite
umm any better way besides pressing the print key?
eeh? my question was is there any way NOT to clear the clipboard by doing this? anyways this is not a proper way of getting a screenshot. I guess there's a way using APIs, I can't rememberQuote:
Originally posted by Pirate
It's another way than Print key
is there any ENUM that has all the values of the keys? it feels a little awkward this wayQuote:
Originally posted by phrozeman
That's used to make an screenshot from the current window... it's the same when u press ALT+PRINTSCREEN
I just like this way .Very easy to use .I got very complicated API code but it's very very complicated .
err it's ok, post it :)Quote:
Originally posted by Pirate
I just like this way .Very easy to use .I got very complicated API code but it's very very complicated .
sorry I can't now .....lol:D :D
Sure, you save the clipboard contents to a variable first, then get the screenshot, then bring it into another bitmap variable. Now just restore the old content back to the clipboard, it happens so quick that it is like it never happened.Quote:
Originally posted by MrPolite
eeh? my question was is there any way NOT to clear the clipboard by doing this? anyways this is not a proper way of getting a screenshot. I guess there's a way using APIs, I can't remember
Storing it to Clipboard , makes some delay .I will try your way now :D .Quote:
Originally posted by hellswraith
Sure, you save the clipboard contents to a variable first, then get the screenshot, then bring it into another bitmap variable. Now just restore the old content back to the clipboard, it happens so quick that it is like it never happened.
hellswraith , How can I save the screen shot directly to bitmap ??Is this possible ?
:rolleyes:
this saves the image to my clipboard...how do I print?
Code:Public Function GetScreenCapture( _
Optional ByVal FullScreen As Boolean = False) As Image
' Captures the current screen and returns as an Image
' object
Dim objSK As SendKeys
Dim imgCapture As Image
If FullScreen = True Then
' Print Screen pressed twice here as some systems
' grab active window "accidentally" on first run
objSK.SendWait("{PRTSC 2}")
Else
objSK.SendWait("%{PRTSC}")
End If
Dim objData As IDataObject = Clipboard.GetDataObject()
Return objData.GetData(DataFormats.Bitmap)
End Function