How can I make my webbrowser remember any password and username i enter?
Printable View
How can I make my webbrowser remember any password and username i enter?
What do you mean by webbrowser? Are you talking about an application webbrowser like IE or FireFox or are you talking about the webbrowser control that you use in a VB program? If it's the control you do not make it remember passwords/usernames. This you must do yourself with some sort of external file or database.
I mean the webbrowser control. I can save my passwords in a file, but how can I make the WebBrowser control detect when I login to a page??
You can't in the strict sense of making the browser detect the login. You need to control the page that you are logging into in you VB program. By using the DocumentComplete event of the WebBrowser control you can determine if the current document (or page) is the login page. You have to be familiar with this page (i.e. you need to know it's URL and the names of the fields on the page that are used to enter the username and passwords). Once you know you have this page loaded and the names of the two fields you simply copy the username and password from your file into these two fields and then you must also know the name of the submit button so you can programmaticly "click" on the submit button.
Let's say, for example, I want to automate a login to a website. In an external file I would keep the usernames and passwords. Now let's also say I know exactly the URL of the page that has the username and password fields on it and also the login button. So, for this example, the URL of the page is "http://www.jmswebsite.com/loginpage" and the names of the fields on this page are "userID" and "pass" for the username and password and "login" for the submit button.
Here is a very simple code example of the above.
This example may not exactly solve your problem but it shows the very basics of one way you might approach your problem.Code:Private Sub WebBrowser_DocumentComplete(ByVal pDisp As Object, URL As Variant)
'
'
If URL = "http://www.jmswebsite.com/loginpage" Then
WebBrowser.Document.All("userID").Value = username from your external file
WebBrowser.Document.All("pass").Value = password from your external file
WebBrowser.Document.All("login").Click
End If
'
'
End Sub
You helped me a lot. Thank you. If I manage to solve my problem I will post the code here!!!
Now I have another question. I can't explain it in words but I will show you an exampple:
I have http://www.vbforums.com/showthread.php?t=384076&page=3 and I want to have this: http://www.vbforums.com/ . How can I do this?? (I want it for the favicon)
You can use small tip:
vb Code:
Private Sub Form_Load() WebBrowser1.Navigate "http://www.vbforums.com/showthread.php?t=384076&page=3" End Sub Private Sub WebBrowser1_DownloadComplete() Dim i As Integer Dim SearchString Text1.Text = WebBrowser1.LocationURL SearchString = Text1.Text ' String to search in. SearchChar = ".com" ' Search for "Xp". i = InStrRev(SearchString, SearchChar, , 1) 'InstrRev(stringcheck, stringmatch[, start[, compare]]) Text2.Text = Left(Text1.Text, (i + 3)) End Sub
i tried the 'Custom Right Click Menu' side of the tutorial
but is not working and i don't know why.
am using windows Vista, has it got something to do with it.
my Question is
how can i copy image in web browser control programatically
for example web page which i have loaded into web browser control have got 5 images and if i can right click on each image and save it is alowing me to do it manually but i want to do this autometacally
and i just want to save one image from the page may be this is first image or mid image or last image
how to control the download window
say we browse to http://go.microsoft.com/?linkid=9729747
then it will come up with a save file prompt
we save it
so I want to be able to see if the download is finish or not..
thank you
This is a great post! I have a specific question a little on the advanced side of this topic. I am trying to save "specific" data from the website to tables in access. Here is a small portion of the web site I am dealing with.
I am currently pulling the data using the website control and using this code here to put it into a string but have no idea which way to go now...Code:<div class="details">
<span id="Quals" onclick="javascript: toggleTable(this.id)" class="OutlineIcon">
<img id="imgQuals" src="images/minusIcon.gif" border="0" WIDTH="14" HEIGHT="14"></span>
<span class="detailsHd">ATMS Quals</span>
<table id="tblQuals" border="1" cellpadding="2" cellspacing="0" class="details">
<tr><th>Qual Number</th>
<th>Title</th>
<th>Expires</th></tr>
<tr><td align="left" valign="top" class="Normal">
ADM_MAT </td>
<td align="left" valign="top" class="Normal">
<a href="atms_supv_qualtree.cfm;jsessionid=0e30e09a3ccb91f2c5ca5e806e7d2b2d6176?PID=22644&qualcat=ADM&qualid=_MAT&title=MANDATORY ANNUAL TRAINING" class="Normal">MANDATORY ANNUAL TRAINING </a></td>
<td align="center" valign="top" class="Normal">
10/31/2011 </td></tr>
<tr><td align="left" valign="top" class="Normal">
BASSHIP_WORKER </td>
<td align="left" valign="top" class="Normal">
<a href="atms_supv_qualtree.cfm;jsessionid=0e30e09a3ccb91f2c5ca5e806e7d2b2d6176?PID=22860&qualcat=BAS&qualid=SHIP_WORKER&title=BASIC SHIPBOARD WORKER" class="Normal">BASIC SHIPBOARD WORKER </a></td>
<td align="center" valign="top" class="Normal">
10/31/2011 </td></tr>
<tr><td align="left" valign="top" class="Normal">
BASSHOP_WORKER </td>
<td align="left" valign="top" class="Normal">
<a href="atms_supv_qualtree.cfm;jsessionid=0e30e09a3ccb91f2c5ca5e806e7d2b2d6176?PID=22861&qualcat=BAS&qualid=SHOP_WORKER&title=BASIC SHOP WORKER" class="Normal">BASIC SHOP WORKER </a></td>
<td align="center" valign="top" class="Normal">
10/31/2011 </td></tr>
Thanks allCode:Dim teststring As String
teststring = WebBrowser1.Document.body.innerhtml
@thechazm: For gathering data from table (of HTML), dilenette had posted a sample code that uses ADO to retrieve the information. If you search the forum, you'll find that code. :wave:
Thank you for pointing me in the right direction. The name you referenced though does not seem to be listed in the user directory so I'm just scanning the net now.
Have a good one,
TheChazm
That's because his handle is spelled dilettante
Thanks again. I was able to figure out what I needed by reading http://www.devarticles.com/c/a/HTML/...s-a-Recordset/
I will go read what dilettante posted to maybe get more in depth information but the code was as simple as this:
Thanks again so very much for the responces and help,Code:AtmsQualsNumber = WebBrowser1.Document.getelementbyid("tblQuals").rows(AtmsQualsc).cells(AtmsQualscc).innertext
TheChazm
and how can i get text from webbrowser to my form in vb6
After a very long time of spending working with the webbrowser control I have learned quite a bit as far as how to make it work. Now I think I have hit another stump. I am trying to read a table with no id on a page. The page only has one table on it but I cannot seem to get the code to pickup on it. Any suggestions?
Here is what I have so far:
And I have also tried:Code:AtmsQualsLength = WebBrowser1.Document.getElementsByTagName("table").rows.length
The reason why I am putting table as the table name is because of this postCode:AtmsCoursesLength = WebBrowser1.Document.getelementbyid("table").rows.length - 1
http://www.eggheadcafe.com/software/...lass-name.aspx
Thanks to all
Well I was not able to ever find a good solution for reading a table with no ID instead I used the instr function and with some calculations read the data from its source code. Its a pain and if the format changes then I would have to update the code but here is what I have.
I just wanted to share what I have done so hopefully its usefull to someone.Code:'// Locate and assign Pay Shop
lngSupCode = InStr(WebBrowser1.Document.documentelement.innerhtml, "Pay Shop")
lngSupCode = lngSupCode + 210
strBuildData = Mid(WebBrowser1.Document.documentelement.innerhtml, lngSupCode)
lngSupCode = InStr(strBuildData, " ")
strBuildData = Left(strBuildData, lngSupCode)
strBuildData = Mid(strBuildData, 18)
lngSupCode = InStr(strBuildData, "&") - 1
strBuildData = Left(strBuildData, lngSupCode)
strPayShop = strBuildData
'// Locate and assign Assn'd Shop
lngSupCode = InStr(WebBrowser1.Document.documentelement.innerhtml, "Assn'd Shop")
lngSupCode = lngSupCode + 210
strBuildData = Mid(WebBrowser1.Document.documentelement.innerhtml, lngSupCode)
lngSupCode = InStr(strBuildData, " ")
strBuildData = Left(strBuildData, lngSupCode)
strBuildData = Mid(strBuildData, 14)
lngSupCode = InStr(strBuildData, "&") - 1
strBuildData = Left(strBuildData, lngSupCode)
strAssignedShop = strBuildData
'// Locate and assign Supv.
lngSupCode = InStr(WebBrowser1.Document.documentelement.innerhtml, "Supv.")
lngSupCode = lngSupCode + 200
strBuildData = Mid(WebBrowser1.Document.documentelement.innerhtml, lngSupCode)
lngSupCode = InStr(strBuildData, " ")
strBuildData = Left(strBuildData, lngSupCode)
strBuildData = Mid(strBuildData, 16)
lngSupCode = InStr(strBuildData, "&") - 1
strBuildData = Left(strBuildData, lngSupCode)
strSupCode = strBuildData
'// Locate and assign Shift
lngSupCode = InStr(WebBrowser1.Document.documentelement.innerhtml, "Shift")
lngSupCode = lngSupCode + 200
strBuildData = Mid(WebBrowser1.Document.documentelement.innerhtml, lngSupCode)
lngSupCode = InStr(strBuildData, " ")
strBuildData = Left(strBuildData, lngSupCode)
strBuildData = Mid(strBuildData, 14)
lngSupCode = InStr(strBuildData, "&") - 1
strBuildData = Left(strBuildData, lngSupCode)
strShift = strBuildData
Thanks,
TheChazm
how to set Page size for this control
and
how to set Page orientation L/p
i have use this control as Report Viewer in my application
some report on Landscape and some Portrait
some page A4 and Some Legal
Please Help Me
WebBrowser control does not have a landscape/portrait setting. You change the width and height of the control to the size you want.
.Width = 8.5 and .Height = 11 will give you portrait whereas .Width = 11 and .Height = 8.5 will give you landscape. Just like CDRIVE told you in post #103. What else do you want?
I am trying to learn the DOM rather than doing what I have done in the past, parsing out an entire HTML page. I don't seem to "get" the DOM for some reason.
I am attempting to use the example here but I can't seem to find the "alt=xxxx" values within the AnchorElement.
I am using this block of code above from this thread:
The code above finds all the "href" info from all the links like this in the document, but how do I programatically find what the "alt" value is that is associated with these links? There is no supported attribute for "alt" that I can find, i.e. HTMLlinks.alt <<< INVALIDCode:Option Explicit
Private Sub Form_Load()
WebBrowser1.Navigate "www.vbforums.com"
End Sub
Private Sub WebBrowser1_DownloadComplete()
'you must add the "Microsoft HTML Object Library"!!!!!!!!!
Dim HTMLdoc As HTMLDocument
Dim HTMLlinks As HTMLAnchorElement
Dim STRtxt As String
' List the links.
On Error Resume Next
Set HTMLdoc = WebBrowser1.Document
For Each HTMLlinks In HTMLdoc.links
STRtxt = STRtxt & HTMLlinks.href & vbCrLf
Next HTMLlinks
Text1.Text = STRtxt
End Sub
Here is the HTML snipit that HTMLlinks.href finds. I need to know the alt=xxx value associated with it:
Code:<a href="main.php?g2_itemId=28"><img src="main.php?g2_view=core.DownloadItem&g2_itemId=68&g2_serialNumber=2" width="200" height="86" id="IFid1" class="ImageFrame_none giThumbnail" alt="Pyramids"/></a>
Thanks!
I have a very large photo gallery on a system where the DB got corrupted. Good news is I can view my old gallery but I just can't add anything to it. I have recreated a second image of it on another URL with all the photos but no descriptions of any of them. I need to copy over the descriptions. I am currently trying to use Webbrowser control to copy all the text from the corrupt gallery to the new gallery.
I have a Webbrowser1 and Webbrowser2 session set up with the 2 screens I want to copy from and to. I would like to learn to do this in the browser control rather than copy/paste if possible, but I will ultimately take advise on anything that works.
There are around 36 input fields to copy on each page but they exist as 2 types with different names. Here are the 2 types:
Copy from/to Field type 1:
Copy from/to Field type 2:Code:<input type="text" id="summary_130" size="60"
name="g2_form[items][130][summary]" value="The road to Alaska was a long and hard one.l"/>
<h4> Keywords </h4>
Of course my code will use the item numbers in the brackets [129], [130] etc to identify what goes where but how do I get started with a browser control to copy and paste from these two types of fields, an Input "value" and a textarea data-string?Code:<textarea id="description_129" rows="4" cols="60"
name="g2_form[items][129][description]">Land travel to Alaska is a long and challenging task for anyone to undertake.</textarea>
Thanks!
Did you ever find an answer to this question?? I have a similar issue.
I would like to get information from an html table that looks like this.
<tr class="vcard">
<td style="border-bottom: 1px solid gray"> </td>
<td style="border-bottom: 1px solid gray"><span class="tel">(###) ###-####</span> </td>
<td style="border-bottom: 1px solid gray"><br><strong><span class="fn org">ANY Insurance Agency</span></strong><br>
<span class="adr">
<span class="street-address">Any Address</span><br>
<span class="locality">ThisState</span><br>
<span class="region">MO</abbr>
</span>
</td>
<td style="border-bottom: 1px solid gray"> </td>
</tr>
This is more html code but im only trying to access "fn", "tel", "fn org",
"street-address","locality", and"region".
Here are so facts i know. They list the agents info under a vcard element. Under that element there are name, tel, and orgainize listed. Then the address information is listed under the element "adr". So i need to loop throught the information getting each set of agent information
It's a catch 22; if you understood this stuff well enough to code in it, then you wouldn't be coding in it ;-)
I still don't grasp the DOM myself but being a lame hacker who codes mostly by example, this helped me a lot. It sort of enumerates most of the major parts of the DOM. I have altered my own version of it in fact with about 3 more screens and a verbose log file that even borders on being unreadable since it doubles down on so many example calls to the DOM. I use it as a shell to go to the website I plan to manipulate and find what I am looking for and go from there.
I am not saying this will work for you, but for the most part I just run this, peruse through the output until I find what I am looking on one of the display output panels and then "cheat" by locating the VB code that produces the shortest path to accessing the info you are searching for.
If you are into bass-ackwards coding like me, maybe this will help get you started:
http://vb-helper.com/howto_get_webbrowser_text.html
Also don't make the same "first mistake" I made by thinking that if you log into a session manually with IE that your VB browser control session code testing will automatically be logged in too just because you have open an active conventional IE user session with the same website. They are separate and you will have to code any log-in sequence into your routine as well.
i love u all :p
hi, is it possible do determine whether a text (SPAN element) text is visible or not?
i tried:
body.parentElement.innerText
body.parentElement.outerText
even i manually select all (Ctrl+A) then paste into a text box and still that text (text is "invalid captcha warning" exits. but not visible in the control/browser..
but i need to get is it visible or not to track if user put correct cpathca or wrong..
i hope i a clear and waiting for someones help...
best regards
kamrul Hassan
this thread has been very useful, many thanks !
But I still have some problems.
My application is very simple: to prepare a series of map printout from Google Maps, for a list of points I have in a DB.
So I loop through the point, send the correct address to google maps and get the image on the webbrowser object in my form. Then issue the print command using pdf creator as printer.
The problem is that I would like to launch the procedure and get all the printout, but at now I must have put a msgbox after each point; without it the printout are empty, because the print command does not wait for the page to complete.
May someone give ne a hint ?
thx
David
Can anyone help on how to simulate typing, which is a combination of onkeydown, onkeypress and onkeyup events?
regards
Hello,
I'm trying to write a simple routine that write a text in the page http://tinywebdb.appspot.com/storeavalue and press the button "Store a value".
Looking the html source of the page, the name of the first field il "Tag", the name of the second field is "Value" and the name of the button is "fmt"
My test code is
WebBrowser.Document.All("Tag").focus
WebBrowser.Document.All("Tag").Value = "xxxxxx"
WebBrowser.Document.All("Value").focus
WebBrowser.Document.All("Value").Value = "yyyyyy"
WebBrowser.Document.All("fmt").Click
but nothing happen on the last row (don't click)
Any idea?
Thank you, Gianluca
How can i get the url of the site that is going to get navigated?Is there a property of webrowser for it?
Thanx in advance..
Is "Disabling functions appropriately" code on the first page supposed to disable CTRL+P? If so, it does not.
Is there a third way of disabling CTRL+P besides hooking keyboard or using WBCustomizer.dll?
Checkbox in a page, how to control it
in the website, the checkbox i wanna check, the code is like this
<input type="checkbox" onchange="groupCheck(this.checked)">
and from your guide, WebBrowser1.Document.GetElementById("PersistentCookie").Checked = True 'checked
that i cant find, help me out with this, i'm using visual studio 2008