I am trying to auto-populate a webserver html page using VB6 and the webbrowser control.
I can go to the URL, get it to auto log-in, and then change the URL to one of the site's webpages.....but I cannot populate a input type="file"
field using the ".value" statementbecause (I understand) this is seen as a basic security risk by Microsoft and not allowed.
So, I am wondering if I can use Sendkeys or another method in VB6 to fill in the field, and if so, how do I identify the field, focus to it, and then use Sendkeys to populate it on the web page?
The problem is that the web page uses a "Browse" button to open a file dialog box so you can find and select the file you want, but I already know the name I want to select, and then there is a "Send" button once the file is selected. I can activate the Send button event no problem, but with no file name entered in the firmware file name field, I get an error returned.
The SECOND problem I have is that once you send the Send button event, a Java Alert box opens which has an "OK" button on it, which I havent figured out (yet) how to programmatically emulate and create a click event for in VB6.
I have browsed the web and experimented for a few nights to get further but have thus far not got any further in this quest. Any help or directions to a tutorial or example would be greatly appreciated.........
My (simple) VB6 code thus far;
Dim starttimer, delaytime
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, url As Variant)
If url = "http://126.96.36.199/" Then
WebBrowser1.Document.All("username").Value = "admin"
WebBrowser1.Document.All("password").Value = "admin"
delaytime = 5 ' wait for login to be completed
ElseIf url = "http://188.8.131.52/html/cfg_update.html" Then
' need to identify "filename entry" field on cfg_update.html webpage and setfocus on it
' how ????
SendKeys "C:/Updater/NewConfig.dat", True ' send filename to filename entry field
WebBrowser1.Document.All("submit").Click ' click the "Send" button on the page
Private Sub Form_Load()
Timer1.Enabled = False
DLstart = False
Private Sub TimerLoop1()
Timer1.Enabled = True
starttimer1 = Timer
Do While Timer < starttimer1 + delaytime
Timer1.Enabled = False
the relevant website source code is;
<input type="file" name="firmware" />
<input name="submit" type="submit" value="Send" onClick="alert('NOTE - This may take several minutes.\r\nPlease wait.');progress.style.display = 'inline';">
<span id="progress" style="display:none">
<p align="center"><img src="images/ajax-loader.gif"></p>
<!-- InstanceEndEditable -->