RSS Forums RSS

send text to browser text field

Please support our VB.NET advertiser: DiscountASP.NET – 3 Months Free on VB.NET Web Hosting
Thread Solved
Reply
Posts: 10
Reputation: tableray is an unknown quantity at this point 
Solved Threads: 0
tableray tableray is offline Offline
Newbie Poster

send text to browser text field

  #1  
Jan 14th, 2009
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?
AddThis Social Bookmark Button
Reply With Quote  
Posts: 2,404
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 209
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: send text to browser text field

  #2  
Jan 14th, 2009
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.
Reply With Quote  
Posts: 650
Reputation: Teme64 is on a distinguished road 
Solved Threads: 106
Teme64's Avatar
Teme64 Teme64 is offline Offline
Practically a Master Poster

Re: send text to browser text field

  #3  
Jan 14th, 2009
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:
  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}")
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the VB.NET Forum
Views: 915 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:28 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC