Sign in to follow this  
Followers 0
ne1l

Fail to close Mozilla Dialog when use title

8 posts in this topic

Hi

I have been experimenting using autoit to close browser dialog's; I have been able to close the dialog using the CLASS attribute but not the Title. Does anyone know how to close the dialog using the Title of the window?

ie.

1. Use firefox to open http://babelfish.yahoo.com/

2. Click translate button without entering any text and mozilla dialog is displayed

3. If I execute the following using the CLASS attribute the dialog closes

$i=0

Do

WinWaitActive("[CLASS:MozillaDialogClass]")

WinClose("[CLASS:MozillaDialogClass]","");

Until $i = 100

4. but if I try to use the Title the dialog does not close

$title = "The page at http://babelfish.yahoo.com says:"

; set the select mode to select using substring

AutoItSetOption("WinTitleMatchMode","2")

$i=0

Do

WinWaitActive("$title")

WinClose("$title")

Until $i = 100

Any ideas why AutoIt can identify the dialog using the CLASS attribute and not the Title?

Thanks in advance for any help given

Neil

Share this post


Link to post
Share on other sites



Are you sure that's the window's title and not just the document's? What does the Window tab of AU3Info.exe look like when pointed to that?

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi

Find below window information:

>>>> Window <<<<

Title: The page at http://babelfish.yahoo.com says:

Class: MozillaDialogClass

Position: 2552, 395

Size: 326, 126

Style: 0x14C80084

ExStyle: 0x00000101

Handle: 0x00060934

>>>> Control <<<<

Class: MozillaWindowClass

Instance: 1

ClassnameNN: MozillaWindowClass1

Name:

Advanced (Class): [CLASS:MozillaWindowClass; INSTANCE:1]

ID:

Text:

Position: 0, 0

Size: 320, 94

ControlClick Coords: 94, 31

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x00040842

>>>> Mouse <<<<

Position: 2649, 455

Cursor ID: 0

Color: 0xECE9D8

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

>>>> Hidden Text <<<<

Share this post


Link to post
Share on other sites

This works fine for me:

#include <GuiConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global $hParent = GUICreate("The page at http://babelfish.yahoo.com says:", 300, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit", $hParent)
GUICtrlCreateButton("Test", 100, 100, 100, 30)
GUICtrlSetOnEvent(-1, "_Buttonclick")
GUISetState()

While 1
    Sleep(10)
WEnd

Func _Buttonclick()
        Local $hWin = WinGetHandle("The page at http://babelfish.yahoo.com says:", "")
        $sTitle = WinGetTitle($hWin)
        MsgBox(64, "Result", "HWND = " & $hWin & @CRLF & "Title = " & $sTitle)
        Sleep(1000)
        WinClose($hWin)
EndFunc   ;==>Button3Click

Func _Quit()
    Exit
EndFunc   ;==>_Quit

Try the same method on your window.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi

Thanks for your time .. I can see how autoit interacts well in your script with the title of a CLASS 'AutoIt v 3 GUI'.. but the problem I am having seems to be specifically with the title of browser dialog's.

Have you got a working example of an autoit script identifying a browser dialog i.e Class: MozillaDialogClass by it's title?

Neil

Share this post


Link to post
Share on other sites

It's the WinWaitActive($title) which is screwing it up. If you remove that it works as expected. Not sure how to solve this, but probably the WinTitleMatchMode doesn't work with WinWaitActive (just guessing)

Share this post


Link to post
Share on other sites

I just ran this and then created the popup in Firefox:

WinWaitActive("The page at http://babelfish.yahoo.com says:", "")
Local $hWin = WinGetHandle("The page at http://babelfish.yahoo.com says:", "")
$sTitle = WinGetTitle($hWin)
MsgBox(64, "Result", "HWND = " & $hWin & @CRLF & "Title = " & $sTitle)
Sleep(1000)
WinClose($hWin)

It worked just fine. Adding Opt("WinTitleMatchMode","2") to the top of the script didn't change anything either; still works. I can't make it fail.

Looks like you have issues with your environment.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

thanks very much for your help .. it was the the "Local $hWin = WinGetHandle($title, "")" step that I was missing .. once I get the handle of the dialog I can now close dialogs using both firefox & IE

all the best

neil

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