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