Sign in to follow this  
Followers 0
bills

Need help closing an opened IE window

17 posts in this topic

#1 ·  Posted (edited)

when im visiting a page, a popup appears. This popup has different titles every time. Im trying to get my script to get the full adress url to the page in that popup but i cant seem to get it to attach to a variable.

This is the code as i have it now.. I have tried a few different versions but noone seem to be able to attach the latest window to $grabsite. The popup doesnt contain a control called "Internet Explorer_Server1" but it contains a control called "Internet Explorer_Server".

Func Button13()
    $title = WinGetTitle("Microsoft Internet Explorer")
    $winclass1 = WinGetHandle($title)
    MsgBox(0, "Handle", $winclass1)
    WinActivate($title)
    $grabsite = _IEAttach($title)
    If @error Then
        If @error = 7 Then
            $error = "No Match"
        ElseIf @error = 5 Then
            $error = "Invalid Value"
        ElseIf @error = 0 Then
            $error = "No Error"
        Else
            $error = "Unknown Error"
        EndIf
        $svar = MsgBox(1, "Error:", $error)
    EndIf
        If $svar = 2 Then
            _IEQuit($oIE)
            _IEQuit($oIE2)
            Exit
        Else
    $grabbedurl = _IEPropertyGet ($winclass1, "locationurl")
    MsgBox(0, "Grabbed url:", $grabbedurl)
    _IENavigate($oIE2, $grabbedurl)
    _IEQuit($grabsite)
    EndIf
EndFunc

Any ideas?

Edited by bills

Share this post


Link to post
Share on other sites



No one? Im all stuck. Trying everything but im new to all this so it takes a long time to learn. Im thinking maybe handles could work since the _ieattach wont find the window with the correct title?

Share this post


Link to post
Share on other sites

Do you mean the Window Class is "Internet Explorer_Server"?


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Yes either that or IEFrame. Thats the info i get from the autoit v3 window info tool. :rolleyes:

Share this post


Link to post
Share on other sites

I have that enabled already.

Also tried Opt("WinTitleMatchMode", 4) and _IEAttach("[CLASS:IEFrame]").

Didnt work either :rolleyes:

Share this post


Link to post
Share on other sites

How about _IEAttach("Explorer", "WindowTitle").


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

This returns @error = 5 from _ieattach :rolleyes:

Share this post


Link to post
Share on other sites

Ah, try using _IEAttach with the "DialogBox" mode.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Now i dont get any error but it still doesnt work.

This is what i got:

Func Button13()
    $title = WinGetTitle("Microsoft Internet Explorer")
    WinActivate($title)
    $grabsite = _IEAttach($title, "DialogBox")
    MsgBox(0, "attachressult", $grabsite)
    If @error Then
        If @error = 7 Then
            $error = "No Match"
        ElseIf @error = 5 Then
            $error = "Invalid Value"
        ElseIf @error = 0 Then
            $error = "No Error"
        Else
            $error = "Unknown Error"
        EndIf
        $svar = MsgBox(1, "Error:", $error)
        If $svar = 2 Then
            _IEQuit($oIE)
            _IEQuit($oIE2)
            Exit
        Else
    EndIf
    $grabbedurl = _IEPropertyGet ($grabsite, "locationurl")
    MsgBox(0, "Grabbed url:", $grabbedurl)
    _IENavigate($oIE2, $grabbedurl)
    _IEQuit($grabsite)
    EndIf
EndFunc

Seems to hang at "$grabbedurl = _IEPropertyGet ($grabsite, "locationurl")" cause i dont get the messagebox below.

Edited by bills

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Try simplifying your function to trap where the error is occuring. Ex:

Func Button13()
    $title = WinGetTitle("Microsoft Internet Explorer")
    WinActivate($title)
    $grabsite = _IEAttach($title, "DialogBox")
    MsgBox(0, "attachressult", $grabsite)
    $grabbedurl = _IEPropertyGet ($grabsite, "locationurl")
    MsgBox(0, "Grabbed url:", $grabbedurl)
    _IENavigate($oIE2, $grabbedurl)
    _IEQuit($grabsite)
EndFunc

Edit: typo

Edited by mikehunt114

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Yeah i just did this:

Func Button13()
    $title = WinGetTitle("Microsoft Internet Explorer")
    WinActivate($title)
    $grabsite = _IEAttach($title, "DialogBox")
    MsgBox(0, "attachressult", $grabsite)
    MsgBox(0, "Test", "Test")
    $grabbedurl = _IEPropertyGet ($grabsite, "locationurl")
    MsgBox(0, "Grabbed url:", $grabbedurl)
    _IENavigate($oIE2, $grabbedurl)
    _IEQuit($grabsite)
EndFunc

And now it seems to work :rolleyes: just wont close the window i attached ($grabsite) any ideas why? any idea why it wouldnt work with the errorcheckcode in the middle?

Edited by bills

Share this post


Link to post
Share on other sites

Try getting the window handle and closing it that way. As for why it doesn't work with your error code stuff in there, you are checking the expression:

If @erroroÝ÷ ØÞ'¯zØb²+"Ê+­ç-rbè®f(¹ªÞr)àzºè­«"~+b±¦è¢Wö¥¹ëk¹ïßj[ÂÞ'¯{
+ɨ²Ú¶­g²Z'«2¢èZ½é÷öÛµê뢻hj|­)àÉëX¢ë!¢é]mç!yÉ"azö¥¹êzºè®)ìµæ)jëh×6If @error <> 0 ThenoÝ÷ ØZèØ^­ì¨¹Æ§v!jܨº±ën¤ÚuØ­íìË*.¬ìµ«^éíÁ«0®+mzv¬àjËaz·°jÉèzºè®)Ú¶Ö)à¶a{§v2¢ì­éÞ½êà¢)à¶ÞiÈr¢êÈúè¥êíÈg­)Þ=êáj2¢íý­éh¢H§ú+²¶§X¤zØb±«­¢+ÙÕ¹ ÕÑѽ¸ÄÌ ¤(ÀÌØíѥѱô]¥¹ÑQ¥Ñ± ÅÕ½Ðí5¥É½Í½Ð%¹ÑɹÐáÁ±½ÉÈÅÕ½Ðì¤(í]¥¹Ñ¥ÙÑ ÀÌØíѥѱ¤í$½¸ÌäíÐÑ¡¥¹¬å½Ô¹Ñ¡¥Ì(ÀÌØíÉÍ¥Ñô}%ÑÑ  ÀÌØíѥѱ°ÅÕ½Ðí¥±½  ½àÅÕ½Ðì¤(5Í    ½à À°ÅÕ½ÐíÑÑ¡ÉÍÍÕ±ÐÅÕ½Ðì°ÀÌØíÉͥѤ(%ÉɽȱÐìÐìÀQ¡¸(%ÉɽÈôÜQ¡¸(ÀÌØíÉɽÈôÅÕ½Ðí9¼5Ñ ÅÕ½Ðì(±Í%ÉɽÈôÔQ¡¸(ÀÌØíÉɽÈôÅÕ½Ðí%¹Ù±¥Y±ÕÅÕ½Ðì(±Í%ÉɽÈôÀQ¡¸(ÀÌØíÉɽÈôÅÕ½Ðí9¼ÉɽÈÅÕ½Ðì(±Í(ÀÌØíÉɽÈôÅÕ½ÐíU¹­¹½Ý¸ÉɽÈÅÕ½Ðì(¹%(ÀÌØíÍÙÈô5Í   ½à Ä°ÅÕ½ÐíÉɽÈèÅÕ½Ðì°ÀÌØíÉɽȤ(%ÀÌØíÍÙÈôÈQ¡¸(}%EեРÀÌØí½%¤(}%EեРÀÌØí½%Ȥ(á¥Ð(¹%(¹%(ÀÌØíÉÕÉ°ô}%AɽÁÉÑåÐ ÀÌØíÉͥѰÅÕ½Ðí±½Ñ¥½¹ÕÉ°ÅÕ½Ðì¤(5Í    ½à À°ÅÕ½ÐíÉÕÉ°èÅÕ½Ðì°ÀÌØíÉÕÉ°¤(}%9Ù¥Ñ ÀÌØí½%È°ÀÌØíÉÕÉ°¤(}%EեРÀÌØíÉͥѤ(¹%)¹Õ¹

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Okay i get the errorpart but i cant close the window.

This is what i got now:

Func Button13()
    $title = WinGetTitle("Microsoft Internet Explorer")
    WinActivate($title)
    $oIE3 = _IEAttach($title, "DialogBox")
    $grabbedurlhandle = WinGetHandle($title)
    $grabbedurl = _IEPropertyGet ($oIE3, "locationurl")
    $grabbedurlcheck = StringLeft($grabbedurl, 7)
    If $grabbedurlcheck <> "http://" Then
        MsgBox(0, "Error", "Not a valid Url")
    Else
    MsgBox(0, "Grabbed URL:", $grabbedurl & @CRLF & @CRLF & "Opening in the right window!")
    _IENavigate($oIE2, $grabbedurl)
    _IEQuit($grabbedurlhandle)
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

You have to use the IE object variable for _IEQuit:

_IEQuit($oIE3)oÝ÷ ØêÞǦk&ÞÊj{¬zËZÖ«w§vºw-ì)Z)¢µ¢¨¥«­¢+Ù]¥¹-¥±° ÀÌØíÉÕɱ¡¹±¤
Edited by mikehunt114

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

THANKS!

It all works great!

Thank you for all your help and time :rolleyes:

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