Sign in to follow this  
Followers 0
Gaurang

How to handle Firefox Save Dialog

5 posts in this topic

Hi Folks,

I am newbie to Autoit. I am doing some automation with selenium, But selenium can't handle the native dialog box. so for that i use the AutouIt script. I am trying to handle the Save Dialog box of firefox. But seems like AutoIT is not able to identify the buttons on it.

My basic need is to download a file using AutoIT script in Firefox browser on Windows plaform. And for that i am using following script

AutoItSetOption("WinTitleMatchMode","2") ; set the select mode to select using substring
; wait Until dialog box appears
WinWait($CmdLine[1]) ; match the window with substring 
$title = WinGetTitle($CmdLine[1]) ; retrives whole window title 
MsgBox(0,"",$title)
WinActivate($title)

MsgBox(0,"",ControlGetText($title,"","Button1")) // Returns 0
MsgBox(0,"",ControlGetText($title,"","Button2")) // Returns 0
MsgBox(0,"",ControlGetText($title,"","Button3")) // Returns 0
MsgBox(0,"",ControlGetText($title,"","Button4")) // Returns 0
MsgBox(0,"",ControlGetText($title,"","Button5")) // Returns 0

As i not getting the text through ControlID I use it's name. But no Luck.

ControlClick($title,"","Save File")

can anybody tell me why so happening..

post-51475-12471349793149_thumb.jpg

Share this post


Link to post
Share on other sites



Welcome to the forum!

You can use FF.au3 for just about anything in Firefox. All thanks to Stilgar!


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I use this function in FFAddOn to detect standard FF "Save As" Dialogs... check the download Window with AU3Info and adjust the function respectively. Then you've got a handle to the window and you can use controlclick (also check ids with AU3Info).

Edit #1: Tested, readjusted and added example, should detect download dialog now...

Edit #2: Rethought the concept, _Detect_FF_dialog_hWnd() is only useful to detect standard Win dialog associated with FF, the MozillaDialogClass can better be detected with a simple winexist() function.

#include<WinAPI.au3>
#include<WindowsConstants.au3>

While Sleep(10)
    If IsHWnd(_Detect_FF_dialog_hWnd()) Then MsgBox(0, "", "FF File Dialog detected...")
    If WinExists("[CLASS:MozillaDialogClass;]", "") Then MsgBox(0, "", "FF MozillaDialogClass detected...")
WEnd

Func _Detect_FF_dialog_hWnd()
    Local $hWnds
    $hWnds = WinList("[CLASS:#32770;]", "")
    For $i = 1 To $hWnds[0][0]
        If BitAND(WinGetState($hWnds[$i][1], ''), 2) Then
            $hwnd_PID = WinGetProcess(_WinAPI_GetAncestor($hWnds[$i][1], $GA_ROOTOWNER))
            $processlist = ProcessList("firefox.exe")
            For $y = 1 To $processlist[0][0]
                If $processlist[$y][1] = $hwnd_PID Then
                    Return $hWnds[$i][1]
                EndIf
            Next
        EndIf
    Next
    Return 0
EndFunc   ;==>_Detect_FF_dialog_hWnd
Edited by KaFu

Share this post


Link to post
Share on other sites

You can better do this this with the FF.au3 and the _FF_DM.au3. You can handle with them the FireFox-download-manager.

To wait for a window with the "MozillaDialogClass" is useless. This could be any FireFox-window which isn't a browser-window.

Share this post


Link to post
Share on other sites

Hi All,

Can any one please tell me the script to handle this Firefox Save Window

Thanks

Azharpost-74443-0-19812000-1343047169_thumb.j

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