glenn2012 Posted January 16, 2013 Posted January 16, 2013 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=1A call to the web address brings up the save file as dialog box.welcome any ideas.
water Posted January 16, 2013 Posted January 16, 2013 How about function InetGet to download the file? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
glenn2012 Posted January 17, 2013 Author Posted January 17, 2013 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.
glenn2012 Posted January 17, 2013 Author Posted January 17, 2013 Missed this FAQ in the Wikihttp://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3FIt 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" windowTested withControlSend ("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.
JohnOne Posted January 17, 2013 Posted January 17, 2013 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.
glenn2012 Posted January 17, 2013 Author Posted January 17, 2013 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now