Website screenshot with vb6
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
Re: Website screenshot with vb6
Re: Website screenshot with vb6
Code:
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
Re: Website screenshot with vb6
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
Re: Website screenshot with vb6
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 :-)
Edit: Found http://www.vbforums.com/showthread.php?t=398758 which might be more use
Re: Website screenshot with vb6
Quote:
Originally Posted by
smUX
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 :-)
Edit: Found
http://www.vbforums.com/showthread.php?t=398758 which might be more use
thanks for your help all the way, but that still does not help me.
i can now capture the page but its showing a scroll bar with the image, i don't want this.
the link above uses a rtb and a picture box
how do i merge the image capture after scrolling or what is d effect of scrolling at all?
i don't know the technique of scrolling and capturing and merging the captured images
any ideas would be useful please.
Re: Website screenshot with vb6
Quote:
Originally Posted by
VBClassicRocks
Code:
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.
Thanks in advance
Re: Website screenshot with vb6
2 Attachment(s)
Re: Website screenshot with vb6
Hey Cool:
As I see this you need two things:
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.
http://www.iqprosoft.com/qclips.htm
The code to capture the internet page in Q-Clips is all VB6 and the only dependency used is the VB6 web browser.
For your information, I saved this web capture in 4 different flavors. The resulting sizes in bytes are:
.bmp: 15,045,546
.png: 897,412
.jpg: 781,048
.gif: 297,697
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
Re: Website screenshot with vb6
Quote:
Originally Posted by
coolcurrent4u
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?
Here's one I was coding awhile back, only tested it on a few sites so not sure how well it works.
1 Attachment(s)
Re: Website screenshot with vb6
i found this code "ClrDepth6" to convert true colour to 16 colour. i modified to meet my needs.
Re: Website screenshot with vb6
i was actually downsizing an image from a picture control instead of a webpage.
Re: Website screenshot with vb6
Quote:
Originally Posted by
Tom Moran
Hey Cool:
As I see this you need two things:
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.
http://www.iqprosoft.com/qclips.htm
The code to capture the internet page in Q-Clips is all VB6 and the only dependency used is the VB6 web browser.
For your information, I saved this web capture in 4 different flavors. The resulting sizes in bytes are:
.bmp: 15,045,546
.png: 897,412
.jpg: 781,048
.gif: 297,697
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.
Re: Website screenshot with vb6
Hi Cool...
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
Re: Website screenshot with vb6
Quote:
Originally Posted by
Tom Moran
Hi Cool...
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
Re: Website screenshot with vb6
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.
Re: Website screenshot with vb6
Quote:
Originally Posted by
Tom Moran
For some reason the file that EdgeMeal posted in #10 is not there.
sorry bout that,...
I moved it to the original thread here and removed my old version.
Re: Website screenshot with vb6
Cool... download Edgemeal's link. It's pretty much already in the form you need.
Thanks, Edgemeal.
Tom
Re: Website screenshot with vb6
No problem, don't really have a use for this myself, just playing around.
btw, Updated to v2.01, had a Cbyte - should of been a Clng, and removed some unused code.
Re: Website screenshot with vb6
Quote:
Originally Posted by
Tom Moran
Cool... download Edgemeal's link. It's pretty much already in the form you need.
Thanks, Edgemeal.
Tom
do you mind sharing code.