Jump to content

AutoIT script to handle IE " save as" dialogue


Recommended Posts

Hello Everyone,

I am basically new to AutoIt and this forum

I need help in creating an AutoIt script to handle the IE save as dialogue and then want the file to be saved in a specific location (Example C:\users)

I have an AutoIt script which handles the Internet Explorer 'save as ' dialogue as below .

--------------------------------------------------------------------------------------------

AutoItSetOption("WinTitleMatchMode", "2")

WinWait("File Download")

$title = WinGetTitle("File Download")

WinActivate($title)

WinWaitActive($title)

Send("s")

WinWait("Save As")

$title = WinGetTitle("Save As")

WinActivate($title)

WinWaitActive($title)

$filename = ControlGetText($title, "", "Edit1")

$fullpath = $CmdLine[1] & "\" & $CmdLine[2] & "-" & $filename

ControlSetText($title, "", "Edit1", $fullpath)

Send("{ENTER}")

ConsoleWrite($fullpath)

------------------------------------------------------------------------------------------

But can anyone help me in modifying the code so that it saves the file in my desired location

For example if i want to save the file under "C:\users\test.html"

How can i pass this parameter in the AutoIt script

Any help would be highly appreciated

Link to comment
Share on other sites

Use _INetGetSource or InetGet

Press F1 and there are samples in Help file

If you already have links you can do something like array of Names, array of links

.......

for $Indx1 = 0 to $ElCount-1

   $sFileName=String("images\"&$NamesArray[$Indx1]&@MON&@MDAY&@YEAR&".png")
   $hDownload=InetGet($LinksArray[$Indx1], $sFileName, 1, 1)

Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)
Link to comment
Share on other sites

Change this:

$fullpath = $CmdLine[1] & "\" & $CmdLine[2] & "-" & $filename

to

$fullpath = "C:\users\test.html"

Hi Juvigy,

Thanks for your very quick reply :blink:

I modified the code as below:

----------------------------------------------

AutoItSetOption("WinTitleMatchMode", "2")

WinWait("File Download")

$title = WinGetTitle("File Download")

WinActivate($title)

WinWaitActive($title)

Send("s")

WinWait("Save As")

$title = WinGetTitle("Save As")

WinActivate($title)

WinWaitActive($title)

$filename = ControlGetText($title, "", "Edit1")

$fullpath = "C:\Users\Test.html"

ControlSetText($title, "", "Edit1", $fullpath)

Send("{ENTER}")

ConsoleWrite($fullpath)

$title = WinGetTitle("Download Complete")

WinActivate($title)

WinWaitActive($title)

Send("{ENTER}")

-----------------------------------------------------

No problems i can get the file Test.html saved under my C:\Users directory !

However the final Send{ENTER} command does not seems to work

The "Download Complete" dialogue does not get closed ?

How do i get AutoIt to close the D'ownload complete' dialogue"

Many thanks!

Edited by getafix
Link to comment
Share on other sites

Use

WinClose()

Hi Juvigy,

Thanks for the reply

Could you let me know which part of the code should i put the WinClose() statement

I tried putting at the end of my code like below but no luck!

ConsoleWrite($fullpath)

$title = WinGetTitle("Download Complete")

WinActivate($title)

WinWaitActive($title)

Send("{ENTER}")

WinClose()

However the main task of saving the file to my desired location worked !

So i am happy about it :blink:

Link to comment
Share on other sites

Something like this should work:

Change

Send("{ENTER}")
WinClose()

to

WinClose($title)

Check out the help file - there are examples there.

Thanks a lot Juvigy :blink:

I shall implement that when i get to work tomorrow.

Yes i shall have a look at the documentation in detail

Cheers

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