Solved

How can i automate username and password for webcontrol from vb

Posted on 2002-04-30
7
170 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:bcp5190
7 Comments
 

Author Comment

by:bcp5190
ID: 6982053
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
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 100 total points
ID: 6982088
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.
0
 
LVL 13

Expert Comment

by:crazyman
ID: 6982952
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.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 43

Expert Comment

by:TimCottee
ID: 6983047
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
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7017200
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
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7022909
Thanks for "A" grade!
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7022984
Thanks for returning and finalizing this.
Moondancer - EE Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now