Solved

Get data file without through PC download dialog/popup  window from Internet

Posted on 2010-11-20
14
608 Views
Last Modified: 2012-05-10
Dear EE ExpertS,

I get one website for download my data files and when I input edit my product No and press enter key ,the IE7
window will  display data I want according to  my input product No. , and so I try to do testing ,  I try to
disconnect internet  and then after that I try to click its download button in the webpage,the  download popup
window  is  still  comming out or appear  and I still  be able to save the exact file I want after click save button .

So I wonder why I can save the  file even I  disconnect internet ,So I believe it is because when I input edit
the product NO and press enter key , the data file is fetched already into Cache file or memory  in my  PC before
I disconnect internet. So my question is if so, whether I am able to save my file without going through  the
download  or popup memu process  that will help me to save a lot VBA download file  program code and
exceute time with automation

I go to seach to my PC directory, finally I found one directory which is asynchronous to what I nagivate in IE7 before.
In such directory it has so many  sitename and image, files name that   I fire IE website before in recent days

The directory name is like C:\users\myaccount\Appdata\Local\Microsoft\Windows\Temporary Internet Files\Coneten.IE5\P5LBXH2C\
something like that  in Window Vista , it seems it is mirror or Cache file to my PC memory, Is it true ?

In other words, I am able to save files directly from the Temporary Internet Files directory,Is it Right ?
So if so, I am easier to use VBA and following code to check file is existed or not and copy it to my directory from
the Temp Internet File directory, Is it right ? Please advise
Since I have a lot of files want to download in target website, so I prefer to do it in VBA with everything in auto
that will  save a lot of execute time when number of file to be download is huge like 1000 files

I try it before, but it is  fail and it might be not as much as easy I say.. Or  I ask where the Cache file is stored for internet file
in most in our PC 's memory and Cache file directory ?  I know Cache file directory is just a link or mirror to direct our PC
memory location. are those files to be able to be  saved by users ?
Please advise and Thanks

Duncan

Function CheckFileAvailable(sFilePath)
    On Error Resume Next
    Dim oFS
    Dim oFile
    Set oFS = CreateObject("Scripting.FileSystemObject")
    Set oFile = oFS.OpenTextFile(sFilePath, 8, False)
    If Err.Number <> 0 Then
        CheckFileAvailable = "Fileinuse"
      ' Debug.Print "FileinUse"
    Else
        CheckFileAvailable = "Fileisfree"
       'Debug.Print "FileisFree"
    End If
End Function

Sub CopyFile2File(wkdir As String, workbookname As String, wkdir2 As String, workbookname2 As String)
Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")
On Error GoTo Err

 Fso.CopyFile (wkdir & workbookname), wkdir2 & workbookname2  ' Change "\*.*" to "\*.xls" to move Excel Files only
 Exit Sub
Err:
 MsgBox "File path or Files not Found"
 Err.Clear
 
End Sub

Open in new window

0
Comment
Question by:duncanb7
  • 9
  • 2
  • 2
  • +1
14 Comments
 
LVL 6

Expert Comment

by:r3nder
ID: 34181380
Duncan
Here is a simple way to do it
Thanks
R3nder
Do
WinWnd = FindWindow(METSIMCLASSNAME, vbNullString)
DoEvents
Loop Until WinWnd <> 0 Or Now() > tBreak
If WinWnd <> 0 Then
lpWindowName = GetWindowsCaption(WinWnd)
Debug.Print "metsim: " & lpWindowName & ", " & WinWnd

Call SetWindowPos(WinWnd, HWND_TOP, 0, 0, 0, 0, _
SWP_NOSIZE Or SWP_NOMOVE Or SWP_SHOWWINDOW)


Wait 1

Call SendKeys("%(FO)~Y", True) ' Send File|Open command {Enter} Yes
hWndSelect = WinWnd
boolOpenWindow = False ' Don't open the window it is already open
End If

Open in new window

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 34181424
What do you mean by "disconnect internet"?  Browsers usually start fetching files in the background while the 'Save' dialog is open.  If it is a small file, it can finish downloading before the dialog is done.  If it's a large file, it won't be done.

You can copy any files you want from the Temporary Internet Files directory.  But IO suspect that VB is going to use the 'Temp' or 'TMP' directory for the initial download.

When it comes to downloading web sites or a lot of files, HTTrack http://www.httrack.com/ is a good program.  You can download a whole website or just a directory.
0
 
LVL 13

Author Comment

by:duncanb7
ID: 34181486
I am able to do whole automation downloading including related API function such as Postmessag, setcursorpos, sendmessage
etc.. But I don't want to do that, if the file is in Cahce memory I can direct copy the file into my directory from Cache memory
or Temp Internet File Directory.  SInce ther is a lot ide time waiting using API function, for example, when postmessage
to  simulate click donwload button, you need to wait the Dialog window display appear...etc.

So what is simple method to get download file if the file is already in memory or temp direcoty

I mean Disconnect, I try to disconnect internet after i enter product NO and enter key
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 13

Author Comment

by:duncanb7
ID: 34181496
Dear R3nder,

It seems your code is more efficent  than more code, I get some question

1- GetWindowsCaption, what is for ?
2- boolOpenWindow = False ' Don't open the window it is already open

What is this of boolopenWIndow, you are able to save files without downlload window pop up

0
 
LVL 13

Author Comment

by:duncanb7
ID: 34181505
I could not find the API defination of GetWindowCaption in API function.

COuld you provide more code detail ?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 34181561
The file in the cache won't necessarily have the 'correct' file name.  You would have to do a directory search to see if it's there.  

"disconnect internet"?  Are you unplugging the cable or just closing IE7 behind the file download dialog?  If any part of IE is still showing on the screen including a 'Save' dialog, then it is not disconnected or closed.
0
 
LVL 13

Author Comment

by:duncanb7
ID: 34181578
The website is embeded with  Java Applet Application and it is advance stream data system
I enter product No and press enter, and then through window to disconnect
internet that is really easy, and then click the download button  and the file can saved to
my expect. I try many time for the testing, it is no problem at all.

0
 
LVL 13

Author Comment

by:duncanb7
ID: 34181581
I don't close IE7 windows, just go to click start in WIndow menu and click connection icon
and disable the connection, and then enable it, the stream data is activated back
0
 
LVL 13

Author Comment

by:duncanb7
ID: 34181585
That is why I believe the data is on Cahce after I enter No and press enter key and
the testing is also proving that is pretty sure
0
 
LVL 13

Author Comment

by:duncanb7
ID: 34181592
The question is how to save the Cache memory to my expect files without through the
download popup menu that will save might be more than 5 times running time.

For example, saving 0.1 seconds for 1 file and it imply save 100 seconds for 1000 files
If you need to do 300 iteration in one day,you will save 300*100 seconds=30000
ie, equal to 30000/60=500 minutes, In other words, you will save 8.3 hours daily
0
 
LVL 13

Author Comment

by:duncanb7
ID: 34181603
After disconnection, I try open new IE7, then web www.yahoo.com but it is not able
and click connection enable, the yahoo.com is activate back. So you don't worry about
the testing acurracy. We focus on the Cache Memory save into file system in Windows
0
 
LVL 6

Accepted Solution

by:
r3nder earned 500 total points
ID: 34181838
Duncan
1 - GetWindoesCaption() - Gets the caption of the window that currently has focus
2 - boolOpenWindow = False - The window has already ben opened by the dialog box and sent on to download (that page doesnt need opening) Because you already have the file

R3nder
0
 
LVL 33

Expert Comment

by:Norie
ID: 34182979
duncan

What are you actually trying to do?

Have you ever considered that there might be a reason why the data is displayed in an applet and is proving so difficult to download/access?

Also, have you checked you can't access the data via some other route.
0
 
LVL 13

Author Closing Comment

by:duncanb7
ID: 34281758
Thanks for all of you to reply
this mail
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

772 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