Jump to content

Auto download and save failure


Recommended Posts

Hi all,

Have a script that goes to a web site and automatically downloads a CSV file.

this is done once a day and I have the script running in a virtual PC, win XP using windows scheduled tasks.

The script works fine when I am logged into the virtual pc.

However when not logged into the virtual pc the script hangs at the save point.

Below is a code snippet.

$address = web address of csv
$oIE = _IECreate($address, 0, 1, 0, 1)
sleep(1000)
WinWait("File Download)
WinActivate("File Download")
ControlClick ("File Download", "", "[CLASS:Button; INSTANCE:2]")

The failure seems to occur at ControlClick, suspect that this is something to do with the way the virtual PC utilises mouse clicks, have tried send("s") but am a bit of a loss as to how to force the VM to action clicking the save button.

Have also had a play with InetGet, but the site I am pulling the data from uses java and there is not a distinct file name as such, but a call to site with queries to generate the file name. (hope that made sense)

http://www.websitename.com/DashboardControls/Reports/GetCsvReport.ashx?UserAddressId=294&DateTo=16/1/2013%12:00:00%20AM&NumberOfDays=1

A call to the web address brings up the save file as dialog box.

welcome any ideas.

Link to comment
Share on other sites

How about function InetGet to download the file?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Cheers water,

I tried to use InetGet but couldn't get it to function properly.

Think the file is generated from the web call and as such does not exist until the call is made with the appropriate settings in the link, so InetGet would not find a file when the link was used in the function.

Link to comment
Share on other sites

Missed this FAQ in the Wiki

http://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F

It is definately a PC locked issue.

Just not sure why the control functions do not seem to be sending the commands to the "save as" window

Tested with

ControlSend ("File Download", "", "[CLASS:Button; INSTANCE:2]", "{SPACE}")

ControlSend ("File Download", "", "[CLASS:Button; INSTANCE:2]", "{ENTER}")

Suspect it may be to dow with the lck of active windows in a locked state.

Link to comment
Share on other sites

It may also have something to do with the way your browser is configured.

For example I can configure to download to a specific location or choose location on each download.

if I set to choose the filesavedialogue appears, if not, it does not.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

yes I think you are right, found this post.

File Save in internet explorer is coded differently and if the window is not active save cannot be pressed.

And since the PC is locked the window will not be active when I'm trying to perform the operation.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...