Solved

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

Posted on 2010-11-20
14
605 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 82

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
 
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 82

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now