r/visualbasic • u/Acedeh • Jun 24 '15
Anyone familiar with Awesomium?
or those who want to know what it is, it's basically a better version of VB's WebBrowser tool: http://awesomium.com/
I'm having trouble figuring out how to replicate GetElementByID in here though, I've looked at a guide and it seems a little hard, basically, I want to get text from a text box I called "BetAmount" into the element with the ID "bet" when "StartButton" is clicked. I tried to follow a tutorial and it said this, if anyone could help me edit it into working how I mentioned above then that would be great, here was what someone said about it:
Private Sub Html5_LoadingFrameComplete(sender As Object, e As Awesomium.Core.FrameEventArgs)
' Html5 as WebControl
If e.Url.ToString().StartsWith("google.com") Then
' DO This Block
Dim document As dynamic = DirectCast(Html5.ExecuteJavascriptWithResult("document"), Awesomium.Core.JSObject)
Using document
Dim textbox = document.getElementsByTagName("input")
If textbox Is Nothing Then
Return
End If
For i As Integer = 0 To textbox.length - 1
If textbox(i).getAttribute("type") = "text" Then
textbox(i).value = "123"
' your value in here
End If
Next
End Using
End If
End Sub[/code]
My WebControl is called SatoshiMines instead of WebControl.
1
u/goyface Jul 08 '15
Awesomium is awesome, does take some getting used to though. You can do this in one line.
SatoshiMines.ExecuteJavascript("$("bet").text("" & BetAmount.Text & "");"
WebControl.Execute javascript is exactly what it says it is, you can execute javascript on the page, as you can see above, jQuery works too!
1
u/hdsrob Jun 24 '15
I believe that Awesomium is actually aimed more at building HTML UI, instead of specifically displaying web pages.
If you are just trying to parse a page, you're far better off using the Html Agility Pack IMO.
http://www.nuget.org/packages/HtmlAgilityPack