Question

VB .Net - web browser control. Automate clicking on and manipulating popup windows after downloading .exe file

Asked by: lcha

Hello, in addition to my description below I'm attaching a document with some pictures of what I'm trying to do as I think it will be much easier to understand this way.    

I am using webbrowser control to navigate through a website and then download a file.  I have managed to get to the page I need now where I click a link to download a file.  

The file is an .exe file which generates a report that I need to download.   Upon clicking the link, a I get a series of different popups windows (please see attachment).    

There are 2 securities warnings asking whether I want to run the file.   I believe my automation script will need to click yes for both and then another popup for winzip self extractor.   I need to unzip to a specific file director and then click on the "unzip" button.    I need to a way to interact (click buttons, type of text values, etc.)

Any insight or guidance to help me get started on this would be appreciately greatly.   thanks!

  • EE-question.doc
    • 88 KB

    This is the flow and screenshots further describe what I'm trying to accomplish

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-17 at 17:16:42ID24660048
Tags

VB .Net automate manipulate popup window exe file

Topics

Microsoft Visual Basic.Net

,

.NET

,

Microsoft Development

Participating Experts
2
Points
500
Comments
25

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Popup Menu
    I want to create a popup menu on my page similar to the ones used by Microsoft and similar companies. Can anyone help with ideas, source etc.
  2. popup
    I have a popup with a link on it. I need the popup to close when the link is activated and the new page to open in the parent window. It must be easier than it seems.
  3. popup killer help
    Hi Experts, I have installed popkiller. Now, I want to activate my popup is enabled though popkiller is on. Now, I want to used javascript which manipulate runtime the popup.enabled or something like that to become tru, and popup will appear. Any good code help. Regards, H...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: TheLearnedOnePosted on 2009-08-18 at 06:14:20ID: 25122805

I believe that what you need to do with the System.Windows.Forms.WebBrowser control is to handle the Navigating event, set e.Cancel = True, and handle the file downloading yourself, instead of letting the WebBrowser control do that.  You should be able to get the URL from the e.Url.ToString() value.

 

by: N00bDeveloperPosted on 2009-08-18 at 06:18:34ID: 25122846

Hello,
In general, what you need to do here is grab the appropriate window handles and then send the proper message (like click) to the appropriate button.  A windows form and all of the components on the form are considered windows. Each window has a handle and once you get that handle you can use it to interact with that window.

You can determine which window is the appropriate window by looking at its title bar text and its class (for example dialog windows are of class #32770). You can get a lot of information about the windows opening and closing on your computer by using the spy++ utility. When you install visual studio, Spy++ is accessible from the from the Visual Studio Tools under the start menu. This tool will list the window class numbers, title bar text, and the parent window. This information is useful for programmatically finding the appropriate for and then the appropriate control to interact with on that form (they are considered windows).

After you have that information, you can use the following User32.dll API functions to get the window handle for the button that you would like to click and then send the click message to the button. Here is an example using the older AxWebBrowser control, but the windows interaction is the same. This example programmatically populates and html file upload dialog box (via the file browser modal window) and submits it.

Also, here is a link to the needed functions on MSDN:
http://msdn.microsoft.com/en-us/library/dd469351(VS.85).aspx

Option Explicit
 
Imports mshtml
 
Public Class Form1
 
    Dim strPath As String = (Application.ExecutablePath()).Substring(0, (Application.ExecutablePath()).IndexOf("\axWebBrowser_filebox_dialog")) & "\axWebBrowser_filebox_dialog\"
    Dim strUploadFilePath As String = strPath & "file.pdf"
 
    Private Const BM_CLICK = &HF5
    Private Const GA_PARENT = 1
 
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
    Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
    Private Declare Function GetParent Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
    Private Declare Function GetAncestor Lib "user32" (ByVal hwnd As Long, ByVal gaFlags As UInteger) As Long
    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As IntPtr
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String) As IntPtr
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
    Try
        Dim empty As Object = System.Reflection.Missing.Value
 
        Dim strWebPagePath As String = strPath & "normal_fileupload_client.php"
        AxWebBrowser1.Silent = True
        AxWebBrowser1.Navigate(strWebPagePath, empty, empty, empty, empty)
 
    Catch ex As Exception
 
        MsgBox(ex.Message)
 
    End Try
 
End Sub
 
Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
 
    Dim strFileBoxID As String = "filebox1"
 
    PopulateFileBox(strFileBoxID)
 
End Sub
 
Private Sub PopulateFileBox(ByVal strFileBoxID As String)
 
    Try
 
        Dim Document As HTMLDocument
        Dim FileBox As HTMLInputElement
        Document = AxWebBrowser1.Document
    
	    If (Not (Document Is Nothing)) Then
	
            FileBox = Document.getElementById(strFileBoxID)
        	
		    If (Not (FileBox Is Nothing)) Then
            	
                'Timer is being used to bypass modal file open dialog box
			    Timer1.Interval = 100
                Timer1.Enabled = True
                FileBox.click
 
		    End If
    	
	    End If
 
    Catch ex As Exception
 
        MsgBox(ex.Message)
 
    End Try
 
End Sub
 
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
 
    Try
        Timer1.Enabled = False
 
        Dim wnd1 As IntPtr
        Dim wnd2 As IntPtr
        Dim wnd3 As IntPtr
    
        'find the file open dialog-window ("#32770" is the classname for it)
        wnd1 = FindWindow("#32770", vbNullString)
 
        Dim parentFormHandle As IntPtr = Me.Handle
        MsgBox("Form Handle " & parentFormHandle.ToString & " wnd1 parent " & GetParent(wnd1).ToString )
 
	    If (wnd1 <> 0) Then
        
		    If (Me.Handle.Equals(GetParent(wnd1))) Then
            
			    'now.. we're going to find the ComboBox where we normally
                'type a file in at. normally, a ComboBox has an Edit control
                'within it where the text is entered (such as a TextBox)..
                'FindWindowEx is similar to FindWindow(), but it allows us to
                'search for windows within a parent
            
                'find the main ComboBox window.. there normally isn't an
                '*Ex32 version of the control but there was in my case..
			    wnd2 = FindWindowEx(wnd1, 0, "ComboBoxEx32", vbNullString)
            
			    'find the child-window of that ("ComboBox")
			    wnd2 = FindWindowEx(wnd2, 0, "ComboBox", vbNullString)
            
			    'find the child-window of that ("Edit")
			    wnd2 = FindWindowEx(wnd2, 0, "Edit", vbNullString)
            
			    'find the button ("&Open").. we'll need to click this!
                wnd3 = FindWindowEx(wnd1, 0, "Button", "&Open")
            
			    'if the "Edit" and "Button" windows were found...
                If ((wnd2 <> 0) And (wnd3 <> 0)) Then
                
				    'set the text of the "Edit" to our file path
				    SetWindowText(wnd2, strUploadFilePath)
                
				    'click the "&Open" button
				    PostMessage(wnd3, BM_CLICK, 0, 0)
 
                End If
        
		    End If
    
	    End If
 
    Catch ex As Exception
 
        MsgBox(ex.Message)
 
    End Try
 
End Sub
 
End Class
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:

Select allOpen in new window

 

by: lchaPosted on 2009-08-18 at 12:24:59ID: 25126609

Thank you both very much for the responses.   I will try theLearnedOne's  approach 1st as it seems to be the simpler of the two.    

*** TheLearnedOne****

- I'm a beginner to VB .Net so please forgive me for asking what may seem obvious.   Please see my questions and comments below.

- Could you please elaborate more on what you meant by handling the navigating event?    Do I need to create a new subroutine using Handles webbrowser3.navigating? (see code snippet below)

- Please see the approach taken below and in code snippet let me know if I'm going in the right direction.

- I'm not familiar with how to download a file without the webbrowser.   Do you have a code example you could share?   I tried using the "DownloadFile " method of the webClient class.   Not sure if this is the correct approach (see code snippet)

Instead of the approach you suggested, e.Url.ToString(), I got the url already by looping through an element collection of <a> tags.   url = curElement2.GetAttribute("href")

In my original approach I was going to navigate to the url of the .exe file - WebBrowser3.Navigate(url).    Should I bypass this altogether or should I navigate to the url and then cancel on the navigate event of the webbrowser?   (see if what I did in code snippet is headed in the right direction)

Private nav As Boolean
nav = False
 
...
...
...
 
' Once this program navigates to the page needed, retrieve the url (to the .exe file) to download the file.   Instead of navigating to the file through the webbrowser, get it another way such as below for example:
 
****Notice the "nav" flag I set to true here that is used in the Webbrowser3_Navigating subroutine (See at bottom of code snippet)***
 
nav = True
WebBrowser3.Navigate(url)
 
' this doesn't seem to work
Dim webc As New System.Net.WebClient()
webc.DownloadFile(url, "test")
 
 
'HERE IS A SUBROUTING TO HANDLE WEBBROWSER3.NAVIGATING EVENT
Private Sub Webbrowser3_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser3.Navigating
        If nav = True Then
            e.Cancel = True
            docComplete = True
        End If
End Sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:

Select allOpen in new window

 

by: TheLearnedOnePosted on 2009-08-18 at 13:50:38ID: 25127534

1) You already have a Navigating event handler, so you don't need another one.

2) The System.Net.WebClient is a simplified wrapper for the System.Net.HttpWebRequest, which you can use to download files with the DownloadFile.

 

by: lchaPosted on 2009-08-18 at 14:56:29ID: 25128054

Thanks.

If I understand your correctly, I don't need to create the event handler that I included in the code snippet is that right?

If I already have a navigating event handler, where or in what way do I handle the Navigating event, you mentioned, "set e.Cancel = True"   Can you give an example?   Where do I do that?

Also, it also sounds like you are saying that I can use system.net.webclient to download the file. (as you said, it's just a simplified wrapper).   Of all the available methods, "DownloadFile" seems to be the most relevant but is it the right method to use?   Looking at the parameters the function accepts, it doesn't seem like this function will allow me save the file, give it a name, and save to a particular directory on a server or my own machine.

' this doesn't seem to work
Dim webc As New System.Net.WebClient()
webc.DownloadFile(url, "test")

Here's what I find in object browser for this function:

Public Sub DownloadFile(ByVal address As String, ByVal fileName As String)
     Member of System.Net.WebClient
Summary:
Downloads the resource with the specified URI to a local file.

Parameters:
address: The URI from which to download data.
fileName: The name of the local file that is to receive the data.

Exceptions:
System.Net.WebException: The URI formed by combining System.Net.WebClient.BaseAddress and address is invalid.  -or- filename is null or System.String.Empty.  -or- The file does not exist.  -or- An error occurred while downloading data.
System.NotSupportedException: The method has been called simultaneously on multiple threads.




 

by: TheLearnedOnePosted on 2009-08-18 at 16:54:48ID: 25128605

It sounds like you have a little more complicated setup than you showed.  If you have the right address, which you get from e.Url.ToString(), for the download file, then you cancel the navigation, and download the file with the WebClient.  I don't have any examples for what you are trying to do, so I hope that we can come up with this together.

"System.Net.WebException: The URI formed by combining System.Net.WebClient.BaseAddress and address is invalid."
What arguments are you passing for DownloadFile?

"System.NotSupportedException: The method has been called simultaneously on multiple threads."
This is a little tougher to discern, since you might have implied multiple threads, instead of explicit threads.

 

by: lchaPosted on 2009-08-18 at 17:23:30ID: 25128785

If I type e.Url.ToString().   Intellisense, does not pick up anything for url.  it's not an option to choose.

For downloadFile I pass the following:
Dim webc As New System.Net.WebClient()
webc.DownloadFile(url, "test")

The url string looks something like this:
http://XXXXXX.com/user/u_report_giver.asp?Report=f_iv200907.exe

I assign a value to the string as follows in the code below:

       For Each curElement3 As HtmlElement In theElementCollection4
                    Dim controlText2 As String = curElement3.GetAttribute("InnerText").ToString
                    Debug.Print(controlText2)
                    If controlText2 = "XXXXInventory" Then
                        url = curElement3.GetAttribute("href")

 

by: lchaPosted on 2009-08-18 at 17:46:21ID: 25128873

You mentioned instead of of using the webbrowser control, I should be able to download myself.    I thought perhaps this approach is to eliminate the 2 securities warnings (in the attachment) because they could be related specifically to the webbrowser.

The other important step in the process I want to be sure came across is to unzip a file to a specific directory.   When running through the flow manually on the browser, clicking pass the 2 browser security warnings, then unzipping the file (clicking on the button to unzip and selecting location), there is no option to choose a file name to save as.    Clicking on unzip creates a file named IV200907.txt and saves to the location specified.   I need the ability to change the name of this file.

 

by: TheLearnedOnePosted on 2009-08-19 at 10:30:20ID: 25135155

Does your application work with a single web page, or should it be dynamic to support multiple web pages?

 

by: lchaPosted on 2009-08-19 at 11:07:35ID: 25135541

The application starts at a particular url and navigates through multiple web pages to get to a destination web page.    When it gets to this page, it finds a specific link and clicks the link to download.    

Unless I answered your question, could you elaborate on what you meant by it being dynamic to support multiple web pages?    

Thanks.

 

by: TheLearnedOnePosted on 2009-08-19 at 11:28:05ID: 25135729

Here is an example form that connects to http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx.  When you click on a download link, the system will give you a dialog box.  For a single, static page, you wouldn't need the dialog box, since you would know what the file name should be.

There is a list of URLs that the web page might auto-navigate to.  If you are trying to make a system that works with dynamic web pages, where you can't predict the possible URLs, it would be much more difficult.

Imports System.Net
 
Public Class Form1
 
    Private m_skipList As List(Of String)
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        ' Build a list of URLs that are possible navigation links that need to be skipped.
        m_skipList = New List(Of String)()
        m_skipList.Add("about:blank")
        m_skipList.Add("http://www.microsoft.com/library/mnp/2/aspx/listener.aspx")
        m_skipList.Add("http://view.atdmt.com/MRT/iview/155397295/direct;wi.120;hi.240/01?click=")
    End Sub
 
    Private Sub WebBrowser1_Navigating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
        Dim url As String = e.Url.ToString()
        If Not m_skipList.Contains(url) AndAlso url.StartsWith("http") AndAlso url <> Me.WebBrowser1.Url.ToString() Then
            e.Cancel = True
            DownloadFile(e.Url.ToString())
        End If
    End Sub
 
    Private Sub DownloadFile(ByVal address As String)
 
        Dim fileName As String = Me.BrowseForSaveFile()
 
        If Not String.IsNullOrEmpty(fileName) Then
            Dim client As New WebClient()
            client.DownloadFile(address, fileName)
        End If
 
    End Sub
 
    Private Function BrowseForSaveFile() As String
        Using dialog As New SaveFileDialog()
            dialog.Title = "Enter file name"
            dialog.ShowHelp = False
            dialog.SupportMultiDottedExtensions = True
            dialog.CheckFileExists = False
            dialog.CheckPathExists = True
            dialog.CreatePrompt = True
            dialog.Filter = "All files (*.*)|*.*"
            dialog.ValidateNames = True
            dialog.RestoreDirectory = True
 
            If dialog.ShowDialog(Me) Then
                Return dialog.FileName
            End If
 
            Return ""
        End Using
    End Function
 
End Class
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:

Select allOpen in new window

 

by: lchaPosted on 2009-08-19 at 12:30:42ID: 25136374

So that we're on the same page, let me clarify...
 
The automation script I wrote uses webbrowser to navigates through multiple web pages.   When it gets to the destination page, this page has multiple hyperlinks to reports such as below:

Feb 2009 Inventory
March 2009 Inventory
April 2009 Inventory
May 2009 Inventory
June 2009 Inventory
July 2009 Inventory
August 2009 Inventory

Say I click on the link for "March 2009 Inventory" link the url is:
http://xxxxxxx.com/user/u_report_giver.asp?Report=f_iv200903.exe

All of the other hyperlinks will be essentially the same except the name of the exe file will differ based on the date of the report selected.    

For July 2009 Inventory" link the url will be:
http://xxxxxxx.com/user/u_report_giver.asp?Report=f_iv200907.exe

Does this make more sense now?

 

by: TheLearnedOnePosted on 2009-08-19 at 12:32:43ID: 25136397

Do you have to navigate through all the pages, or can you go directly to the download page, with the appropriate arguments in the URL?

 

by: lchaPosted on 2009-08-19 at 13:20:02ID: 25136889

I have to navigate through all the pages.

I have to log in to the website first, at the next page I choose from a list of states all hyperlinks.  
- AZ (hyperlink)
- CA (hyperlink)
- NV (hyperlink)
....
.....
....

I'll choose, AZ for example.....

After clicking on the AZ hyperlink and reaching the next page, I choose from a variety of report links based on date as described above.    
e.g. July 2009 Inventory (hyperlink)

After I download the file, the webbrowser needs to go back to the previous web page and choose the next state, and the same report link to download the report again for the relevant month.

 

by: TheLearnedOnePosted on 2009-08-19 at 13:29:27ID: 25136987

OK, sometimes you can bypass all the startup stuff, by passing a URL with the proper query string values.

I don't see any reason for parsing through the HTML to get the URL for the download.  If you navigate the pages, and check the URLs in the DocumentComplete event handler, and then perform the necessary operations to get to the final download page.  Then, you can parse through the HTML, get the links for all the downloads, and download all the files at one time, without having to navigate between pages.

 

by: lchaPosted on 2009-08-19 at 14:06:26ID: 25137356

In my case, the page with all "States" names, each a hyperlink.
The url for this page is
http://xxxxx.com/user/u_user.asp

When I scroll over the hyperlink for each state you can see the following at the bottom of the web page.
e.g. AZ (hyperlink) .... javascript:frmSubmit('AZ', 1,1);
e.g. CA (hyperlink).... javascript:frmSubmit('CA', 14,1);

After clicking any hyperlink, the next page url is always the same.  
http://XXXXXX.com/user/u_Report.asp

I don't see any name value pairs, etc. passed in the url.


 

by: TheLearnedOnePosted on 2009-08-20 at 07:43:25ID: 25143141

I am trying to point out different options, but I clearly don't completely understand what you are working with (on the outside looking in).  

I have done a lot of work with the WebBrowser control, HttpWebRequest, WebClient, Microsoft.mshtml, HTML parsers, etc., to automate web pages, but each situation is unique.  

I am trying to determine your exact requirements, and give you good directions to take.

 

by: lchaPosted on 2009-08-20 at 09:03:41ID: 25144179

I just created a document and added it as an attachment (visuals say so much more).   I appreciate all your time and effort on this!    Please let me know if this makes things more clear and any other questions to help clarify the requirements.

  • Workflow.docx
    • 135 KB

    Step by step flow, screenshots, and descriptions

 

by: TheLearnedOnePosted on 2009-08-21 at 08:06:51ID: 25152603

Is it just me, or does the u_user.asp page post to u_Report.asp with the state code, division ID, and state level flag?

This still sounds like you should be able to simulate this, without having to navigate forward and backward between the pages.

 

by: lchaPosted on 2009-08-21 at 10:25:34ID: 25153891

awesome, that helps a lot.    thank you!       Now I just need to figure out how to programatically set those values in the form and submit.     Also, need to download the file address the windows popups, winzip extractor, etc.

I feel already I should give points but we have been addressing some other questions other than the original (which is good!) and still have yet to address the original question.     I have more questions and don't want you to feel cheated of points or having to spend too much time on one question.    Do you want me to open up new questions concerning this project or keep it all together?  



function frmSubmit(astrStateCode, aintDivisionID, aintStateLevelFlag)
{
	document.frmRetrieveFiles.action = "u_Report.asp";
	document.frmRetrieveFiles.hdnStateCode.value = astrStateCode;
	document.frmRetrieveFiles.hdnDivisionId.value = aintDivisionID;
	document.frmRetrieveFiles.hdnStateLevelFlag.value = aintStateLevelFlag;
	document.frmRetrieveFiles.submit();
	}
 
<input type="hidden" name="hdnStateCode" id="hdnStateCode">
<input type="hidden" name="hdnDivisionId" id="hdnDivisionId">
<input type="hidden" name="hdnSupplierCD" id="hdnSupplierCD">	
<input type="hidden" name="hdnStateLevelFlag" id="hdnStateLevelFlag">
<input type="hidden" name="hdnUserLevel" id="hdnUserLevel" value="SU">	
 
 
<form name="frmRetrieveFiles" id="frmRetrieveFiles" method="post"><!--table border="0" cellspacing="0" cellpadding="4" width="100%" align="center" border="0">
 
<a href="javascript:frmSubmit('AZ', 1, 1);">Arizona</A></font></b></td></tr><tr><td>&nbsp;&nbsp;&nbsp;<b><font face="Verdana,Arial,Helvetica" size="1">
<A href="javascript:frmSubmit('CA',14,1);">California</A></font></b></td></tr><tr><td>&nbsp;&nbsp;&nbsp;<b><font face="Verdana,Arial,Helvetica" size="1">
<A href="javascript:frmSubmit('CO',17,1);">Colorado</A></font></b></td></tr><tr><td>&nbsp;&nbsp;&nbsp;<b><font face="Verdana,Arial,Helvetica" size="1">
<A href="javascript:frmSubmit('FL', 15, 1);">Florida</A></font></b></td></tr><tr><td>&nbsp;&nbsp;&nbsp;<b><font face="Verdana,Arial,Helvetica" size="1">
<A href="javascript:frmSubmit('HI', 7, 1);">Hawaii</A></font></b></td></tr><tr><td>&nbsp;&nbsp;&nbsp;<b><font face="Verdana,Arial,Helvetica" size="1">
...
...
...

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:

Select allOpen in new window

 

by: lchaPosted on 2009-08-21 at 12:56:42ID: 25155264

Instead of finding a way to programaticaly click the browser back button, to go from
a. www.xxxxxx.com/user/u_report.asp
back to
b. www.xxxxxx.com/user/u_user.asp

Seems I can just use webbrowser1.navigate(www.xxxxx.com/user/u_user.asp)

I could set the values programatically (doing the same as what javascript does):
    webbrowser1.Document.Body.All("hdnStateCode").SetAttribute("Value", "CA")
    webbrowser1.Document.Body.All("hdnDivisionID").SetAttribute("Value", "14")
    webbrowser1.Document.Body.All("hdnStatelevelflag").SetAttribute("Value", "1")

You mentioned being able to simulate the u_user.asp post but is there any benefit to being able to simulate this over just navigating back to the u_user.asp and programatically clicking on the hyperlink

Why not just let javascript do the job of populating those values?

I think the direction you were headed was to find a way to to download all the files at once right?    It would be great, but do you think that is still possible?

 

by: lchaPosted on 2009-08-21 at 15:56:38ID: 25156594

I created a new thread specifically requesting help on downloading the file and the best approach.

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_24672888.html

Will leave this one open and can award points for further help to download all files at once if possible and to get past user window popups for browser security and winzip extract to unzip file.

 

by: lchaPosted on 2009-08-22 at 10:39:28ID: 25159518

Please Dismiss this earlier question to you -  ""You mentioned being able to simulate the u_user.asp post but is there any benefit to being able to simulate this over just navigating back to the u_user.asp and programatically clicking on the hyperlink    Why not just let javascript do the job of populating those values?"

The information you provided helped me to simplify my code and an error I was getting earlier.  Instead of retrieving an HTMLElement collection and looping through to find what I needed ... I am just assigning the input values for the form directly myself using setattribute() and those values for each state, that I found on the page.  

Again, if you have any thoughts on how to a way to approach downloading all the files at once, please let me know.   thanks and I hope you have a great weekend!

 

by: lchaPosted on 2009-08-23 at 16:44:37ID: 25164783

I am going to close this and award some points for the help provided so far.   I have create a new question as a continuation.

http://www.experts-exchange.com/index.jsp?qid=24675255

 

by: lchaPosted on 2009-08-23 at 16:54:28ID: 31616867

Thank you both for your you suggestions and help on this issue.  I really appreciate your time.   Your comments and feedback have definitely helped me to certain degree.   This is the first time I've developed in VB .Net and I haven't done any development for years so I'm struggling!    I opened a new question related and continuined from this question.   If you have time to assist please see  - http://www.experts-exchange.com/index.jsp?qid=24675255

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...