How can i automate username and password for webcontrol from vb

I have a WebBrowser control and a command button on form now when i click on button i want to display www.yahoo.com on WebBrowser1. The Control works fine but it reqires username and password. now how can i enter username and password from VB to "Enter Nework Password" dialog box so user are not require to enter username and password manually.

How can i hard code username and password and enter using SendKeys "username"
SendKeys "{tab}"
SendKeys "password"
SendKeys "{enter}"


I'm trying following code but somehow it doesnot work
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function IsWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long


    FrmFormName.WebBrowser1.Navigate "http://www.yahoo.com"
   
    Dim hWnd As Long
    Dim iResult As Long

    Const lpCaption = "Enter Nework Password"
    hWnd = FindWindow(vbNullString, lpCaption)
    If hWnd <> 0 Then
        iResult = SetFocusAPI(hWnd)
        SendKeys "{Tab}"
        DoEvents
        SendKeys "username"
        DoEvents
        SendKeys "{Tab}"
        DoEvents
        SendKeys "password"
        DoEvents
        SendKeys "{enter}"
        DoEvents
    End If
bcp5190Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bcp5190Author Commented:
Look like FindWindow(vbNullString, lpCaption) is executing before it opens a dialog box. i also try to put loop and doevents but didn't help
Richie_SimonettiIT OperationsCommented:
see code on how to automate login in hotmail, populating user, passw and push the button at:
wwww.angelfire.com/realm/vb-shared/index.html under "IE DOM..." link.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crazymanCommented:
If it is Challenge/response authentication you can place it in the url.

http://Username:Password@www.website.com

If it is a custom authentication script then you can post the username password in the headers of the request.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

TimCotteeHead of Software ServicesCommented:
bcp5190 you should put your findwindow code etc in the following event rather than immediately after the navigate2 statement to ensure that the page is fully loaded before attempting to input the information.

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)

End Sub
MoondancerCommented:
You currently have 12 open questions here, all of which need your attention.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20262180.html
http://www.experts-exchange.com/questions/Q.20276446.html
http://www.experts-exchange.com/questions/Q.20276618.html
http://www.experts-exchange.com/questions/Q.20277354.html
http://www.experts-exchange.com/questions/Q.20280405.html
http://www.experts-exchange.com/questions/Q.20280044.html
http://www.experts-exchange.com/questions/Q.20290228.html
http://www.experts-exchange.com/questions/Q.20295100.html
http://www.experts-exchange.com/questions/Q.20295588.html
http://www.experts-exchange.com/questions/Q.20299810.html
http://www.experts-exchange.com/questions/Q.20300923.html
http://www.experts-exchange.com/questions/Q.20300927.html



*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
Richie_SimonettiIT OperationsCommented:
Thanks for "A" grade!
MoondancerCommented:
Thanks for returning and finalizing this.
Moondancer - EE Moderator
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.