I have written an application which extracts a list of URL's (currently in Internet Explorer cache) from an XML file and displays them in a data grid view. From here i would like to launch Internet Explorer in a hidden mode and capture an image for each of the selected URL's in the data grid view. Is this possbile? If so what is the best way to go about it? Or does anybody have any other suggestions on other ways i could recieve the same result?

Thanks

Well you could start Internet Explorer in hidden mode like this:

Dim p As New ProcessStartInfo("iexplore.exe")
p.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(p)

*You Can Also Start It As Minimized, Maximized, or Normal by Replacing Hidden*

In reference to the screenshot, you could invoke the Print Screen button to take a shot of the entire screen but with the Internet Explorer window hidden, this probably would not work. Here is the code to invoke the Print Screen button:

Dim b As Bitmap = New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height, Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(b)
g.CopyFromScreen(My.Computer.Screen.Bounds.X, My.Computer.Screen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)
b.Save("Screenshot.jpg", Imaging.ImageFormat.Jpeg)

This will not only take the snapshot of your screen but it will also save it as the file name "Screenshot" in your documents folder.

Hope this gets you started in the direction that you need!

Thanks for the reply NetJunkie. I should have been a bit clearer in my above post. currently i am looping through my data grid view of URL's opening the selected URL's in Internet Explorer taking a snapshot of them and then saving a copy of the image. The problems with what i have are as follows:

1) When taking the snapshot it only captures what is on the screen (it does not show the entire web page as it is unable to scroll to the bottom of the page)

2) I would like the whole process to be hidden

Here is a snippet of my code showing what my application currently does:

Dim name As String = ""
        For Each rows As DataGridViewRow In DataGridView3.Rows
            If Convert.ToBoolean(DirectCast(rows.Cells(0), DataGridViewCheckBoxCell).Value) = True Then

                'Put Internet Explorer into 'Offline Mode'
                My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "GlobalUserOffline", "1", Microsoft.Win32.RegistryValueKind.DWord)

                Dim value As New Object
                value = rows.Cells(2).Value.ToString
                If value = Nothing Then
                    ' Do Nothing because row is empty
                Else

                    Dim IE As New InternetExplorer
                    IE.Visible = True
                    IE.Navigate(value)
                    IE.Offline = True
                    IE.FullScreen = True
                    System.Threading.Thread.Sleep(2000)

                    Dim width As Integer, height As Integer
                    width = IE.Width
                    height = IE.Height
                    Using image As New Bitmap(width, height)
                        Using graphics__1 As Graphics = Graphics.FromImage(image)
                            Dim p As Point, upperLeftSource As Point, upperLeftDestination As Point
                            p = New Point(0, 0)
                            upperLeftSource = New Point(0, 0)
                            upperLeftDestination = New Point(0, 0)
                            Dim blockRegionSize As Size = New Size(width, height)

                            graphics__1.CopyFromScreen(upperLeftSource, upperLeftDestination, blockRegionSize)

                        End Using

                        name = rows.Cells(2).Value
                        'Remove http://, https://, www.
                        Dim name2 As String = name.Replace("http://", " ")
                        name2 = name2.Replace("https://", " ")
                        name2 = name2.Replace("www.", " ")

                        'Replace all illegal file name characters from the URL and replace with "_"
                        name2 = name2.Replace("?", "_")
                        name2 = name2.Replace("/", "_")
                        name2 = name2.Replace(":", "_")
                        name2 = name2.Replace("*", "_")
                        name2 = name2.Replace("?", "_")
                        name2 = name2.Replace(":", "_")
                        name2 = name2.Replace("<", "_")
                        name2 = name2.Replace(">", "_")
                        name2 = name2.Replace("|", "_")

                        Dim character As String
                        Dim name3 As String = ""
                        Dim i As Integer = 0
                        Dim MaxFilePath As Integer = 253 - Form4.PathToimages.Length
                        Do While i <= MaxFilePath
                            If name2.Length > i Then
                                character = name2.Chars(i)
                                name3 = name3 + character
                                i = i + 1
                            Else
                                Exit Do
                            End If
                        Loop
                        image.Save(Form4.PathToimages + "\" + name3 + ".bmp")

                    End Using
                    System.Threading.Thread.Sleep(1000)

                    IE.Quit()

                End If
            End If
        Next

The reason i put Internet Explorer into offline mode is that all pages i wish to view are currently in cache and i do not want to download any active content.

Does anybody have any ideas on how i could achieve a similar result with the whole process being hidden?

Thanks,
Brent

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.