943,703 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3584
  • VB.NET RSS
Jan 14th, 2009
0

send text to browser text field

Expand Post »
i want to fill up the userID and password fields of the yahoo mail login page with the click of a button on the form but just cant get it right.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

WebBrowser1.Navigate("https://login.yahoo.com/config/login_verify2?.intl=sg&.src=ym")

Private Sub Button1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseClick

WebBrowser1.Focus()
SendKeys.SendWait("userID")
SendKeys.SendWait("{TAB}")
SendKeys.SendWait("password")
SendKeys.SendWait("{Enter}")


it just skips the yahooID field and fills out the password field. what is wrong or is there a better way of doing it?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tableray is offline Offline
10 posts
since Jan 2009
Jan 14th, 2009
0

Re: send text to browser text field

Eah, I'm not sure how long SendWait waits, but when I did this type of thing in visual basic 6, I had to add sleeps after every sendkeys event... I also had to add doevents (app.doevents). Even then, it never worked 100% correctly. It has been my years of experience (doing this type of thing for like 14 years) that using sendkeys NEVER behaves the way you want it to. Even if you get it right 90% of the time, some kind of fluctuation in the processor, it would send data to the wrong window. Even if the user simply accidentally clicks say, the desktop.... or an instant message pops up, etc, etc. Basically there is absolutely no fault tolerance with Sendkeys.

That said, you might want to manually follow the steps, to make sure that say, the username box gets the focus on the page immediately. What I mean is, perhaps since the page is built into the app, maybe "userid" isn't the textbox with focus.... so, load up your app, and watch..... if the userID /DOES/ get focus, then maybe you are sending the userID data too soon (ie: javascript in the web-page sets the focus to the textbox... if the page is loading, and has not yet run that javascript, then the username box won't have focus, and you'll skip right over it. [See what I mean about fault tolerance?]. Maybe try adding a sleep right after WebBrowser1.Focus(). Let me know if that helps it.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 14th, 2009
0

Re: send text to browser text field

First, this is Visual Basic 4 / 5 / 6 i.e. classic VB forum. You're question is about VB.NET which has it's own forum here in DaniWeb.

WebBrowser1.Focus() sets the focus to the webbrowser control but there's no guarantee where the focus is in the web page its displaying.

Anyway, I got following key sequence to work:
VB.NET Syntax (Toggle Plain Text)
  1. WebBrowser1.Focus()
  2. SendKeys.SendWait("+{TAB}") ' Tab back one step
  3. SendKeys.SendWait("{TAB}") ' Tab forward one step
  4. SendKeys.SendWait("userID")
  5. SendKeys.SendWait("{TAB}")
  6. SendKeys.SendWait("password")
  7. SendKeys.SendWait("{Enter}")
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: 2008 Opening, editing and saving text files
Next Thread in VB.NET Forum Timeline: Hardware interface with VB.Net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC