Sign in to follow this  
Followers 0

Automating the IE Save AS file Dialog

4 posts in this topic

Posted

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")

adarsh12in likes this

Share this post


Link to post
Share on other sites



Posted

Which version of windows? I have found that the dialogs are not the same...

Share this post


Link to post
Share on other sites

Posted

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!)

Share this post


Link to post
Share on other sites

Posted

Look for solutions in my sig, below.

Dale

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

  • Recently Browsing   0 members

    No registered users viewing this page.