Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21990

Problems Taking a Screenshot of a Website

$
0
0
So i have code that goes out to a URL, takes a screenshot and saves the image to a folder. I'm having a problem with websites that put focus on an HTML element such as a search box (Yahoo) or a login textbox (Facebook). I have tried the following solutions to remove focus from the HTML element:

Use RemoveFocus():

Dim Elem As HtmlElement = wb.Document.GetElementById("searchQuery")
Elem.RemoveFocus()


Edit the <script> that puts focus in the search box and replace it with Blur():

Dim Elem As HtmlElement = wb.Document.GetElementById("searchQuery")
Dim script As HtmlElement = Elem.NextSibling
If script.InnerHtml.Contains("searchQuery") Then
Dim repl As String = script.InnerHtml.Replace("focus", "blur")
script.SetAttribute("text", repl)
End If


Inject my own <script> to utilize Blur():

Dim script1 As HtmlElement
script1 = wb.Document.CreateElement("script")
script1.SetAttribute("type", "text/javascript")
script1.SetAttribute("text", "Function script_load() {document.getElementById(" & "searchQuery" & ").blur();}")
wb.Document.Body.AppendChild(script1)
wb.Document.InvokeScript("script_load()")


None of these options have worked. I keep receiving a blank image as the screenshot. Also, I'm using a webbrowser completed loading listener to ensure the page has completely loaded. Any ideas on what else I can do to remove focus from the search box?

Thanks,
Nick

Viewing all articles
Browse latest Browse all 21990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>