Link to home
Start Free TrialLog in
Avatar of aflorence07
aflorence07

asked on

How do I redirect or avoid WebBrowser Control from Stealing Focus

I am trying to write a program that uses a WebBrowser control to automatically login to a particular website to upload data to the website.  Basically, the UI of the website is poor and permits many input mistakes to happen, so I need to write a program which acts as a frontend to the hidden website.  There is a usernameTextBox, userpasswordTextBox, and loginButton.  I have the autologin functional, but when the main webpage loads, my usernameTextBox loses focus and becomes frustrating to input username and password.
Avatar of William Elliott
William Elliott
Flag of United States of America image

if you have the "name" for the fields, then you shouldn't have to worry about this,..


This is what the HTML tag looks like for the www.google.com search field:

<input maxLength=256 size=55 name=q value="">

Let's say I've got a combo box named cboData

The following code will look for an INPUT tag with name = "q". When it finds it, the current value of the combo box will be put into the search field.


Set docCurrentHTML = MyBrowser.Document.documentElement.All

For Each Item In docCurrentHTML

If Item.tagName = "INPUT" Then
If Item.Name = "q" Then
Item.Value = cboData.Text
Exit For
End If
End If

Next Item



is this what you're referring to?
http://www.vbforums.com/archive/index.php/t-160521.html
ASKER CERTIFIED SOLUTION
Avatar of aflorence07
aflorence07

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Closed, 500 points refunded.
Computer101
EE Admin