| | |
send text to browser text field
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Jan 2009
Posts: 10
Reputation:
Solved Threads: 0
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?
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?
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.
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.
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:
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)
WebBrowser1.Focus() SendKeys.SendWait("+{TAB}") ' Tab back one step SendKeys.SendWait("{TAB}") ' Tab forward one step SendKeys.SendWait("userID") SendKeys.SendWait("{TAB}") SendKeys.SendWait("password") SendKeys.SendWait("{Enter}")
Teme64 @ Windows Developer Blog
![]() |
Similar Threads
- SpeedUp Your Window XP Never Than Before (Windows tips 'n' tweaks)
- value pass from one script to another script (JavaScript / DHTML / AJAX)
- modify script (Perl)
- need help deserately! virus won't go away! (Viruses, Spyware and other Nasties)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- This ought to be simple - extra spaces (PHP)
- Linux Audio Streaming (live!) using Ices and Icecast (*nix Software)
Other Threads in the VB.NET Forum
- Previous Thread: 2008 Opening, editing and saving text files
- Next Thread: VB.Net and sql server connection
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access add application arithmetic array assignment basic box button buttons center check click code combo component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net exists file-dialog firewall folder ftp hardcopy image images isnumericfuntioncall math mobile module mssqlbackend mysql navigate networking opacity output peertopeervideostreaming picturebox1 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left savedialog serial sqldatbase storedprocedure string tcp temp text textbox timer toolbox trim txttoxmlconverter updown useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml






