Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2014, 04:53 AM
Registered User
 
Join Date: Jan 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using VB6 to populate a webserver html page?

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;

Code:
  Dim starttimer, delaytime
  Dim url
  
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, url As Variant)
  If url = "http://123.123.123.123/" Then
    WebBrowser1.Document.All("username").Value = "admin"
    WebBrowser1.Document.All("password").Value = "admin"
    WebBrowser1.Document.All("button").Click
    delaytime = 5        ' wait for login to be completed
    Call TimerLoop1
    WebBrowser1.Navigate "http://123.123.123.123/html/cfg_update.html"
    Exit Sub
  ElseIf url = "http://123.123.123.123/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
    Exit Sub
  End If
End Sub

Private Sub Form_Load()
    Timer1.Enabled = False
    DLstart = False
    WebBrowser1.Navigate "http://123.123.123.123"
End Sub
 
Private Sub TimerLoop1()
  Timer1.Enabled = True
  starttimer1 = Timer
  Do While Timer < starttimer1 + delaytime
    DoEvents
  Loop
  Timer1.Enabled = False
End Sub
the relevant website source code is;

Code:
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="firmware" />
    </p>
    <p align="right">&nbsp;
      <input name="submit" type="submit" value="Send" onClick="alert('NOTE - This may take several minutes.\r\nPlease wait.');progress.style.display = 'inline';">&nbsp;&nbsp;&nbsp;
    </p>
  </form>
  <span id="progress" style="display:none">
  	<p align="center"><img src="images/ajax-loader.gif"></p>
  </span>
<!-- InstanceEndEditable -->





Similar Threads
Thread Thread Starter Forum Replies Last Post
nested do while within php script to populate html menu dwalker1 PHP Databases 0 September 26th, 2013 03:12 PM
Webserver not opening page from Webmatrix 3 giving connection error rsaraogi1 BOOK: Beginning ASP.NET Web Pages with WebMatrix 4 September 2nd, 2013 04:02 PM
Populate Adobe PDF with html form data bfoley Classic ASP Basics 4 January 17th, 2008 09:44 AM
Launching HTML Help in VB6 tknnguyen Pro VB 6 1 October 16th, 2007 02:28 PM
VB6 HTML Help bwhit VB How-To 1 May 13th, 2006 03:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.