Jump to content

How to handle Firefox Save Dialog


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 3 years later...

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