Jump to content
Sign in to follow this  
glenn2012

Auto download and save failure

Recommended Posts

glenn2012

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.

Share this post


Link to post
Share on other sites
water

How about function InetGet to download the file?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
glenn2012

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.

Share this post


Link to post
Share on other sites
glenn2012

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.

Share this post


Link to post
Share on other sites
JohnOne

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.

Share this post


Link to post
Share on other sites
glenn2012

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.

Share this post


Link to post
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
Sign in to follow this  

×