Sign in to follow this  
Followers 0
fract4l

Downloading with _IEFormImageClick

8 posts in this topic

So first off let me just put out there that I have done a fair amount of searching and haven't come across another thread that I felt answered my question all that well. I'm working getting a script to basically login to a website and download a file. It sounds rather easy, but with the source of the site I'm using it is proving to be a tad bit more difficult. I am trying to run this script without it having to be in the foreground.

I'm getting stuck and the download portion. I am able to traverse the page and find the necessary form image to click to initiate the download. Once the button click is simulated I am not sure how to continue. I don't see how an INetGet or any other function is possible with the location of the file being hidden.

HTML Source:

CODE
<td><a onclick="btnFlag_Clicked(this, 'grdList', 0, 0); return false;" title="" href="java script:__doPostBack('grdList$ctl03$ctl00','')" style="color:Black;"><img src="/Centre/images/unchecked.gif" height="16" width="16" border="0"></a></td><td> </td><td align="left" style="white-space:nowrap;">PS_Cardholder</td><td> </td><td align="center" style="white-space:nowrap;">

<input type="image" name="grdList$ctl03$imgDownloadfile" id="grdList_ctl03_imgDownloadfile" src="../images/download_report.gif" style="border-width:0px;" />

AutoIt Script:

CODE
_IEFormImageClick ($oIE, "grdList$ctl03$imgDownloadfile", "name")

FileWriteLine("D:\Share\Get_Mapper_test_log.txt","Clicked the dowload button")

WinWait("nothing", "",3)

ControlSend("File Download", "", "Button2", "Save")

ControlClick("File Download", "", "4424")

It doesn't seem to want to finish the download/Save As. From what I read it is not possible to fore go the Save As box unless I've missed something. Does anyone have another idea of something I could try to finish this script out. Any help is much appreciated!

Thanks,

fract4l

Share this post


Link to post
Share on other sites



It is a purposeful security restriction. Remember that a majority of the things that IE.au3 does with DOM interaction can be done via Javascript on a page and you certainly don't want an arbitrary HTML page in the wild to be able to silently download a file to your system.

The Save As... dialog is a standard Win32 window however and you can interact with it with the standard AutoIt Win* and Control* functions. This can include hiding the window and interacting with its controls with ControlSend.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

It is a purposeful security restriction. Remember that a majority of the things that IE.au3 does with DOM interaction can be done via Javascript on a page and you certainly don't want an arbitrary HTML page in the wild to be able to silently download a file to your system.

The Save As... dialog is a standard Win32 window however and you can interact with it with the standard AutoIt Win* and Control* functions. This can include hiding the window and interacting with its controls with ControlSend.

Dale

Firstly, thanks for responding. Secondly please forgive me if I am missing the obvious here. I completely understand the security reasons behind the source being the way it is, however it is making this rather difficult :) I am running the instance of IE such that $f_visible = 0. Once the form image is clicked it presents the "File Download" window to the screen. I for one reason or another do not seem to be able to have the script interact with this new window even through the control functions. I have doubled checked to ensure I have the correct names/class/instances for the window but without much luck.

currently the code looks like this:

CODE
ControlCommand("File Download", "", "Button2", "{ENTER}")

So am I missing the obvious or making assumptions that are leading me astray?

Thanks.

fract4l

Share this post


Link to post
Share on other sites

Please see Example 2 for _IEAction in the the helpfile (latest beta - V3.2.5.4 or higher). It shows you how to avoid your script hanging after doing a click.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Dale,

Again thanks for the help thus far and hope I haven't become an too much of a nuisance. I have installed the v3.2.5.3 (beta) and do not happen to find a 2nd example of _IEAction in the helpfile. Should the 2nd example be found under the function _IEAction section of the helpfile I have searched for references of IEAction in all the examples but am not sure I found anything that would help me with the Download window that pops up?

Based on the 1st Example I have replaced the need for IEFormImageClick which worked successfully and now use the IEAction.

Thanks again!

fract4l

Share this post


Link to post
Share on other sites

Can I get a website? I'm not that good w/ reading source code yet.


[center]JSON Encoding UDF[/center]

Share this post


Link to post
Share on other sites

Well I realized that the "File Download" window is actually not part of IE at all. I guess I'm just out of luck because I can't get this click save with controlClick unless the File Download Window is in focus. Since the console of the machine is locked it will not work.

Unless anyone has an idea on how to interact with a "file download" window while the machine is locked. Any information would be most helpful.

Thanks,

Share this post


Link to post
Share on other sites

Dale,

Again thanks for the help thus far and hope I haven't become an too much of a nuisance. I have installed the v3.2.5.3 (beta) and do not happen to find a 2nd example of _IEAction in the helpfile. Should the 2nd example be found under the function _IEAction section of the helpfile I have searched for references of IEAction in all the examples but am not sure I found anything that would help me with the Download window that pops up?

Based on the 1st Example I have replaced the need for IEFormImageClick which worked successfully and now use the IEAction.

Thanks again!

fract4l

v3.2.5.3 was not the latest beta at the time of writing that reply - 3.2.5.4 was -- "Please see Example 2 for _IEAction in the the helpfile (latest beta - V3.2.5.4 or higher)". The example I refer to was added in 3.2.5.4.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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  
Followers 0