Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Automating the IE Save AS file Dialog


  • Please log in to reply
3 replies to this topic

#1 steveellis99

steveellis99

    Seeker

  • Active Members
  • 6 posts

Posted 06 November 2011 - 10:15 PM

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







#2 dmob

dmob

    Polymath

  • Active Members
  • PipPipPipPip
  • 235 posts

Posted 07 November 2011 - 10:20 AM

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

#3 steveellis99

steveellis99

    Seeker

  • Active Members
  • 6 posts

Posted 07 November 2011 - 11:42 AM

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

#4 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,976 posts

Posted 07 November 2011 - 06:26 PM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users