# Automate download picture



## korivo (Aug 10, 2004)

hi there!

Im looking for a way to automate the downloading of picture from a webbrowser control in vb6.

Right now, im positioning the cursor with the 'top' and 'left' property of the 'user32.dll.'. I simulate a right click on the image and then simulate a left click on 'save as' menu.... well, you get the picture!!!

So as you can see, its definetly not robust, and its just doesnt work that well.

Any idea how i could do it, with vb6?

It needs to run 24/7

Thanx 
Korivo


----------



## Mosaic1 (Aug 17, 2001)

Does the image file have a name or do you want to download all images from one or more than one web sites?


----------



## Mosaic1 (Aug 17, 2001)

Are you sure you wouldn't rather use the Internet Transfer Control?


----------



## Mosaic1 (Aug 17, 2001)

Let's get Tech Guy's logo and put it in C:\ logos Hope he doesn't mind.

Add a component to your project. The Microsoft Internet Transfer Control.
Drag to your form.

Add this to an event. I used a command button to make it easy.


```
Private Sub Command2_Click()
Dim Bytes() As Byte

Bytes = Inet1.OpenURL("http://tsgstatus.com/images/misc/logo.gif" _
, icByteArray)
Open "C:\logos\TGlogo.gif" For Binary Access Write As #1
Put #1, , Bytes
Close #1
End Sub
```


----------



## korivo (Aug 10, 2004)

great thats works pretty good.

But what if i see a pic on a web page but the link is not shown, so i cannot directly go the images and download it  

Thanx


----------



## Mosaic1 (Aug 17, 2001)

> But what if i see a pic on a web page but the link is not shown, so i cannot directly go the images and download it


right click on the image and choose properties. What does it say? But that's not automated. Not sure what you are doing.


----------



## Mosaic1 (Aug 17, 2001)

To get all the images' src addresses on a page use the Web Browser Control
Here's an example. It will get a list of all images on this thread's page and add them to a list box. You click on any one of them and the Web Browser Control navigates to that image and show it. Rename webBrowser1 as WB1 in Properties.

```
Private Sub Command1_Click()
WB1.Navigate "http://forums.techguy.org/showthread.php?p=1848037&posted=1#post1848037"

End Sub

Private Sub List1_Click()
Dim i%
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
WB1.Navigate2 List1.List(i)
End If
Next
End Sub

Private Sub WB1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim i As Integer, L As Integer
L = WB1.Document.Images.length
For i = 0 To L - 1
List1.AddItem WB1.Document.Images(i).SRC
Next

End Sub
```


----------



## korivo (Aug 10, 2004)

Ok, heres more detail.

The image comes in a outlook type inbox

If i right click the image i have no properties value, its more an outlook menu.

But the email itself is sort of in HTML

here the code when i display the source :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Message

-----Original Message-----
*From:* 
[email protected] [mailto:[email protected]]

*Sent:* August 9, 2004 9:11 AM
*To:* Sebastien 
Tanguay
*Subject:*










*







*
​
In bold, you can see the image there, but there is no link or src to it. Well there is one, but im not so sure how i could use it...

Thanx


----------



## Mosaic1 (Aug 17, 2001)

I have no idea what the address would be for that. You might ask Telus. Are these messages filtered and are you up to date with your Windows Security patches?


----------

