am writing a program that takes website screenshots and save it as jpg or png. this are my plans
1. donwload that page
2. save it on the hard drive
3. load it in an invincible browser (IE)
4. take a full screen shot of the loaded page or save it as image
my problem lies in the last step, i gave not yet figure out how to save it as image or take a full page screen shots, any ideas?
hanks
Programming is all about good logic. Spend more time here
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const WHOLESCREEN As Long = 0 'entire screen
Private Const FOCUSSCREEN As Long = 1 'window with focus
Private Sub ScreenShot(ByVal SavePath As String)
Call keybd_event(vbKeySnapshot, WHOLESCREEN, 0, 0)
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), SavePath
End Sub
Private Sub Command1_Click()
ScreenShot "c:\capture.bmp" '**** change this ******
End Sub
Thanks guys, but the WebBrowser control id giving me problems
1. when loading the page, it pops up error that relate to javascript and ask me if i want to continue, definitely i click yes. But i don't want this. How can i tell it to ignore error and continue loading?
2 when loading the page, i want it to tell me when it has finished loading so i can capture the screenshot
3. i usually move the webbrowser off screen, and make it 1024 x x786 to capture a fuul page, but pages longer than that get cut shot, and sometimes, it just show white blank picture
any ideas here
Programming is all about good logic. Spend more time here
1. in form_load add webbrowser1.silent = true, it *CAN'T be added at design time as it reverts back to false, it has to be added at runtime
2. There are a number of ways to check if a webbrowser is finished, .readystate and .busy are both options, and neither are reliable 100% but if used together you can usually be 100% sure it's complete :-)
3. Blank page either means the capture isn't working or the webpage hadn't downloaded properly. Pages longer than 768 pixels WILL get cut short because you're taking a picture of the visible portion...you need to scroll down and take more pictures then piece them together...this has been mentioned in the forum in the past but I have no idea when or the post as it was ages ago :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
1. in form_load add webbrowser1.silent = true, it *CAN'T be added at design time as it reverts back to false, it has to be added at runtime
2. There are a number of ways to check if a webbrowser is finished, .readystate and .busy are both options, and neither are reliable 100% but if used together you can usually be 100% sure it's complete :-)
3. Blank page either means the capture isn't working or the webpage hadn't downloaded properly. Pages longer than 768 pixels WILL get cut short because you're taking a picture of the visible portion...you need to scroll down and take more pictures then piece them together...this has been mentioned in the forum in the past but I have no idea when or the post as it was ages ago :-)
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const WHOLESCREEN As Long = 0 'entire screen
Private Const FOCUSSCREEN As Long = 1 'window with focus
Private Sub ScreenShot(ByVal SavePath As String)
Call keybd_event(vbKeySnapshot, WHOLESCREEN, 0, 0)
DoEvents
SavePicture Clipboard.GetData(vbCFBitmap), SavePath
End Sub
Private Sub Command1_Click()
ScreenShot "c:\capture.bmp" '**** change this ******
End Sub
i am using your screenshot code to capture Picture1.Picture in my vb app and was wondering if you or anyone know of a way to reduce the file size of capture.bmp after the Picture1.Picture is captured. it is sized at 2.9MB and i'd like to take it down to 100k if possible because i am sending this as an attachment by email.
I tried changing it to capture.jpg but still same size.
1. The ability to save a picture box image as a JPEG.
2. To capture the full screen of a web page even if the web page is longer than the screen.
Resolving the first issue: Attached is a jpeg class solution. No ocx, no dll required. Pure vb code. The attached project contains a demo of the use of the class. Not sure who to give credit to on this one as it's not notated in the code. I believe I downloaded a few years ago from Planet.
Issue #2: This is a little more involved. I assume your looking to get a result as in the image attached (webcapture.zip) to this post.
This was captured and saved in Q-Clips, a windows capture and clipboard extender. This is a program I wrote a few years ago that was done in VB6 and is a program that can be downloaded.
The bmp, jpg and png are all 24bit images. The gif, of course, is 8bit. Attached is the gif just because it was smaller.
If you wish to include the VB6 webbrowser control in your program, then this method would work for you. Let me know and I'll send you the key code parts of using the control to capture a full web page screen.
Tom
Last edited by Tom Moran; Feb 24th, 2010 at 11:08 PM.
Reason: correct web link
1. The ability to save a picture box image as a JPEG.
2. To capture the full screen of a web page even if the web page is longer than the screen.
Resolving the first issue: Attached is a jpeg class solution. No ocx, no dll required. Pure vb code. The attached project contains a demo of the use of the class. Not sure who to give credit to on this one as it's not notated in the code. I believe I downloaded a few years ago from Planet.
Issue #2: This is a little more involved. I assume your looking to get a result as in the image attached (webcapture.zip) to this post.
This was captured and saved in Q-Clips, a windows capture and clipboard extender. This is a program I wrote a few years ago that was done in VB6 and is a program that can be downloaded.
The bmp, jpg and png are all 24bit images. The gif, of course, is 8bit. Attached is the gif just because it was smaller.
If you wish to include the VB6 webbrowser control in your program, then this method would work for you. Let me know and I'll send you the key code parts of using the control to capture a full web page screen.
Tom
Thanks Tom Moran,
But I still have problem capturing and merging at the same time. The reason i need this feature is because am integrating it in a program, so i may not be able to buy your software, as i cannot include it in my app.
One technique of capturing a webpage is that
1. you have determin the page width and height
2. capture the first visible part and save it im memory eg partA
3. calculate the non captured part, scroll down to thid part and capture the second partB
4. merge partA and partB to form the whole
my problem is in 3 & 4
you have som ideas?
4.
Last edited by coolcurrent4u; Feb 25th, 2010 at 04:44 AM.
Programming is all about good logic. Spend more time here
I wasn't suggesting you buy the software. I was asking if you wanted to include the webbrowser in your control, and if so, I would send you the code to capture the entire page. You don't need the method of capture, scroll and merge (or stitch). The image I attached in post 9 was created as one single image.
However, the good news is that Ed (EdgeMeal) has given you the complete solution to your problem in post 10. Download and run his attached demo project. It will give you the code to capture the entire page and save as JPEG. No scrolling, merging or stitching.
The only thing is you will need to add the VB6 web browser to your project. But, as you can see in Ed's project, you don't even need to have it visible on screen.
I wasn't suggesting you buy the software. I was asking if you wanted to include the webbrowser in your control, and if so, I would send you the code to capture the entire page. You don't need the method of capture, scroll and merge (or stitch). The image I attached in post 9 was created as one single image.
However, the good news is that Ed (EdgeMeal) has given you the complete solution to your problem in post 10. Download and run his attached demo project. It will give you the code to capture the entire page and save as JPEG. No scrolling, merging or stitching.
The only thing is you will need to add the VB6 web browser to your project. But, as you can see in Ed's project, you don't even need to have it visible on screen.
Tom
Tanks Tom,
Can i get it then?
thanks
Programming is all about good logic. Spend more time here
For some reason the file that EdgeMeal posted in #10 is not there. I did download it earlier so I'm not sure what happened. It seemed to work fine and was exactly what you needed. Perhaps he pulled it for some reason. Edgemeal?
What I'll do is pull the code I have for capturing a web page. You'll need to combine what I send with the jpeg class in my earlier upload to save the file as jpeg. Give me abit and I'll get it to you.