Jump to content

Automating the IE Save AS file Dialog


steveellis99
 Share

Recommended Posts

Greetings all,

After having recieved and absolute ton of assistance from all the user posts here, I feel obliged to share a bit of code I created to interact with the file-download dialog in IE. There might be better/easier ways, but I sure couldn't find them...or make them work in AutoIT as a newbie. I know there is an INetGet tool, but it won't work on the pages I'm using (security stuff...dynamic linking and my general ignorance). The code below will change the default text to a directory name, click the button, and replace the original file name back into the box. It's probably the equivalent of digital duct-tape, but I hope it can help somebody.

Note: I have the destination directory stored in a variable ($dest) from a FileSelectFolder call. I'm not sure all the sleep() steps are essential, but it doesn't hurt ot have a little patience.

....after having a link clicked elsewhere in the script....snip:

WinWait("File Download")

WinActivate("File Download")

sleep(500)

ControlClick("File Download","","Button2") ; this clicks the default "save" button on the first dialog

WinWait("Save As") ; Wait for the "Save As" box to pop up

WinActivate("Save As")

sleep(500)

$filename=ControlGetText("Save As","Save &in:","Edit1") ;Get the file name before we erase it

ControlSetText("Save As","Save &in:","Edit1","") ; erase the file name to make room for the $dest string

sleep(1000)

ControlSetText("Save As","Save &in:","Edit1", $dest) ; set the Edit1 text to the $dest and hit the button to swithc directories.

ControlClick("Save As","","Button2")

sleep(1000)

ControlSetText("Save As","Save &in:","Edit1", $filename) ; reset the name of the file to the original value.

sleep(1000)

ControlClick("Save As","","Button2")

Link to comment
Share on other sites

My code was created for Windows XP with IE8, but I think the basic idea would work for any version. You might have to use the AutoIT Window Info toolto get the right names for the Edit field and the buttons. The Save As dialog seems to be a Windows window (?!?!) not specifically an IE window, so I think they'll stay consistently named (I HOPE they stay consistently named!)

Link to comment
Share on other sites

Look for solutions in my sig, below.

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

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