Hi
I've just started trying to learn visual basic and I'm trying to to display a captcha image in a picture box.
The site Im trying to make the desktop app for is https://emkei.cz/
Here is the code that I've done so far.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Call navigatetosite()
End Sub
Private Sub navigatetosite()
Try
WebBrowser1.Navigate("https://emkei.cz/", False)
While WebBrowser1.Readystate <> WebBrowserReadyState.Complete
Application.DoEvents()
End While
Call getcaptcha()
Catch ex As Exception
MsgBox(ex.StackTrace)
End Try
End Sub
Private Sub getcaptcha()
Dim doc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
Dim imgRange As mshtml.IHTMLControlRange = CType(doc.body, mshtml.HTMLBody).createControlRange
For Each img As mshtml.IHTMLImgElement In doc.images
If img.GetAttribute("scr").ToString.Contains("https://www.google.com/recaptcha/api/") Then
imgRange.add(img)
imgRange.execCommand("copy", False, Nothing)
PictureBox1.Image = Clipboard.GetDataObject.GetData(DataFormats.Bitmap)
Exit For
End If
Next
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
WebBrowser1.Document.GetElementById("fromname").SetAttribute("value", TextBox1.Text)
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
WebBrowser1.Document.GetElementById("from").SetAttribute("value", TextBox2.Text)
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
WebBrowser1.Document.GetElementById("rcpt").SetAttribute("value", TextBox3.Text)
End Sub
Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
WebBrowser1.Document.GetElementById("subject").SetAttribute("value", TextBox4.Text)
End Sub
Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
WebBrowser1.Document.GetElementById("text").SetAttribute("value", TextBox5.Text)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("btn").InvokeMember("click")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
End Sub
Private Sub TextBox6_TextChanged(sender As Object, e As EventArgs) Handles TextBox6.TextChanged
WebBrowser1.Document.GetElementById("recaptcha_response_field").SetAttribute("value", TextBox6.Text)
End Sub
End Class
Like I say I've just started so all help and advice would be very much appreciated.
Thank You
7 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mario OmarPosted Sep 11, 2014, 11:06 AM
http://support.leadtools.com/CS/forums/43550/ShowPost.aspx
Guest UserPosted Aug 10, 2014, 2:00 AM
http://code.msdn.microsoft.com/windowsapps/Captcha-for-Windows-c5ea873c
Dav LewisPosted Aug 9, 2014, 7:17 PM
To be honest I started losing my way a bit in the code trying different things. I have been reading a lot of different posts on different sites and trying to implement them to suit my needs. which didnt realy work
Guest UserPosted Aug 6, 2014, 9:11 PM
https://developers.google.com/recaptcha/docs/aspnet
but your implementation is different, I mean your getcaptcha() method.
Can you help me understand what you're trying to do in getcapthca() method?
Dav LewisPosted Aug 6, 2014, 7:43 PM
Dav LewisPosted Jul 30, 2014, 4:38 PM
Guest UserPosted Jul 27, 2014, 11:37 PM