Is there an easy method for taking a screenshot and the saving it automaticall?
Thanks in advanmce
Printable View
Is there an easy method for taking a screenshot and the saving it automaticall?
Thanks in advanmce
Take a look @ this thread .
Is it possible to take a screenshot of just a picture box i have?
Why would you want to do that...?
Would you not just be able to "grab the contents" of that pitcure box and use that the same way?
RyanJ
Im creating a client for a game, the game is played inside a picture box. So I want screenshots to be taken of the game not of the entire window.
Cheers :afrog:
This should do what you need. Make sure you install and register the .dll before running. I have included instructions on what you need to do.
Enjoy. :wave:
How aboutVB Code:
SavePicture Picture1.Image, "c:\test.bmp"
That saves the screenshot that's printed into Picture1. The attachment was good, but it still doesn't solve my problem. I'm trying to take a screenshot of a picturebox inside a form, not the whole form.Quote:
Originally Posted by Hack
Thanks
Right, i've managed to get it to work. However i have to drag this annoying picture to the 'object' to get it to work. How can i set my picture box to it already without having to move the image to get the window shot?
this might help...
VB Code:
Private Sub Command1_Click() Dim WndRECT As RECT GetWindowRect SelWnd, WndRECT SavePicture hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp" Set Image1.Picture = hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)) End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.MousePointer = 99 Me.MouseIcon = Picture1.Picture Picture1.Visible = False End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim mousexy As PointAPI GetCursorPos mousexy SelWnd = WindowFromPoint(mousexy.X, mousexy.Y) Me.MousePointer = 0 Picture1.Visible = True End Sub Private Sub Timer1_Timer() Dim mousexy As PointAPI GetCursorPos mousexy label2.Caption = WindowFromPoint(mousexy.X, mousexy.Y) End Sub
Or, if you really feel like it, you can see the whole lot from here.
Did you look at the attachment that I posted? It saves to jpeg, also.
Yeah very helpful. I've sorted the saving out :bigyello:. Now i'm trying to take a screenshot of an object (picturebox).
If you have a look at http://vtforce.com/cruel/window_bitblt.zip , it shows how to drag this picture to an object to take a screenshot of. I want to do this but I dont want to have to use the picture to find the object. I want a command button to automatically take a screenshot of the object. Sorry it's hard to explain.
This is unsolved :(, please help...
Surely you could explain what you want.Quote:
This is unsolved , please help...
Sorry it's hard to explain
Imagine I offered you the services of the best programmer in the world.
He now lives in a cave in Tibet (portable generator).
He has no phone and no Internet.
I visit him once a year.
If you can type up your spec, I will take it to him, and I will return with the completed project.
If he misunderstands your spec, I can take the amendments/corrections/clarification with me 12 months later on my next visit.
Go on, have a wee go at explaining what you want.
Right, I can understand as the subject has sightly changed. I will try to explain in as much detail as possible.
I am trying to take a screenshot of an object within my form. The object is a picture box. I have some code that does this, however you have to move a picture (looks like a crosshairover) the object like below:
http://www.dan-gibbs.com/other/vb01.JPG
So, i am trying to get a screenshot of the picture box (that has a web browser inside) without moving the crosshair image over.
Heres some of the code:
VB Code:
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type PointAPI X As Long Y As Long End Type Dim SelWnd As Long Private Sub Command1_Click() Dim WndRECT As RECT GetWindowRect SelWnd, WndRECT SavePicture hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp" Set Image1.Picture = hDCToPicture(GetDC(SelWnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)) End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.MousePointer = 99 Me.MouseIcon = Picture1.Picture Picture1.Visible = False End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim mousexy As PointAPI GetCursorPos mousexy SelWnd = WindowFromPoint(mousexy.X, mousexy.Y) Me.MousePointer = 0 Picture1.Visible = True End Sub Private Sub Timer1_Timer() Dim mousexy As PointAPI GetCursorPos mousexy label2.Caption = WindowFromPoint(mousexy.X, mousexy.Y) End Sub Private Sub form_load() WebBrowser1.Navigate ("http://www.runescape.com") End Sub
For the whole code take a look at this:
http://vtforce.com/cruel/window_bitblt.zip
Thanks! Hope that clears a few things up...
Hi,
Thanks for explaining more.
The attachment is the same one you posted before, I think ?
I could not work out how to use either of them.
I click the button.
I click and drag the mouse, and let go.
I see the rectangle whilst doing that
What am i supposed to do next.
I'm attaching screen shot of the latest zip, in case you attached the wrong one.
The function uses the window handle to retrieve picture content. So you must provide the correct window handle to be able to take the screenshot. If you don't want to have to drag the crosshairs then you'll have to use a series of FindWindow and FindWindowEx api calls.
Luckily if you're just wanting a screenshot of a picture box, then you can just use Picture1.hWnd
That being said, here's the revised button event:
I tested and it should work. If not, post the problem.Code:Private Sub Command1_Click()
Dim WndRECT As RECT
GetWindowRect Picture2.hwnd, WndRECT
SavePicture hDCToPicture(GetDC(Picture2.hwnd), 0, 0, (WndRECT.Right - WndRECT.Left), (WndRECT.Bottom - WndRECT.Top)), App.Path & "\ok.bmp"
End Sub