Results 1 to 20 of 20

Thread: Website screenshot with vb6

  1. #1

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Question 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
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  2. #2
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: Website screenshot with vb6

    Option Explicit should not be an Option!

  3. #3
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    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

  4. #4

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    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
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  5. #5
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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
    Last edited by smUX; Jan 5th, 2010 at 10:01 AM.
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    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.

  6. #6

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Website screenshot with vb6

    Quote Originally Posted by smUX View Post
    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.
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  7. #7
    Addicted Member
    Join Date
    Dec 2009
    Location
    B.C. Canada
    Posts
    206

    Re: Website screenshot with vb6

    Quote Originally Posted by VBClassicRocks View Post
    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

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Website screenshot with vb6

    Check this link...

    http://www.xtremevbtalk.com/archive/...p/t-44717.html

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9
    Addicted Member
    Join Date
    Jul 2007
    Posts
    228

    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
    Attached Files Attached Files
    Last edited by Tom Moran; Feb 24th, 2010 at 11:08 PM. Reason: correct web link

  10. #10
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Website screenshot with vb6

    Quote Originally Posted by coolcurrent4u View Post
    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.
    Last edited by Edgemeal; Feb 25th, 2010 at 05:37 AM.

  11. #11
    Addicted Member
    Join Date
    Dec 2009
    Location
    B.C. Canada
    Posts
    206

    Re: Website screenshot with vb6

    i found this code "ClrDepth6" to convert true colour to 16 colour. i modified to meet my needs.
    Attached Files Attached Files

  12. #12
    Addicted Member
    Join Date
    Dec 2009
    Location
    B.C. Canada
    Posts
    206

    Re: Website screenshot with vb6

    i was actually downsizing an image from a picture control instead of a webpage.

  13. #13

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Website screenshot with vb6

    Quote Originally Posted by Tom Moran View Post
    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.
    Last edited by coolcurrent4u; Feb 25th, 2010 at 04:44 AM.
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  14. #14
    Addicted Member
    Join Date
    Jul 2007
    Posts
    228

    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

  15. #15

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Website screenshot with vb6

    Quote Originally Posted by Tom Moran View Post
    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
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  16. #16
    Addicted Member
    Join Date
    Jul 2007
    Posts
    228

    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.

  17. #17
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Website screenshot with vb6

    Quote Originally Posted by Tom Moran View Post
    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.

  18. #18
    Addicted Member
    Join Date
    Jul 2007
    Posts
    228

    Re: Website screenshot with vb6

    Cool... download Edgemeal's link. It's pretty much already in the form you need.

    Thanks, Edgemeal.

    Tom

  19. #19
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    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.

  20. #20

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Website screenshot with vb6

    Quote Originally Posted by Tom Moran View Post
    Cool... download Edgemeal's link. It's pretty much already in the form you need.

    Thanks, Edgemeal.

    Tom
    do you mind sharing code.
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width