Sign in to follow this  
Followers 0
Viscouse

Identify new IE window w/random name

5 posts in this topic

#include <IE.au3>
Opt("WinTitleMatchMode", 2)
_IENavigate ($oIE, "http://somewebsite.com") ;assume title is "First"
_IELinkClickByText ($oIE, "click me")
WinSetState("Explorer", "", @SW_MAXIMIZE)

The first 4 lines work no sweat. The idea is that when the link is clicked, it opens a new IE window that has a completely random title, so I'm having a really hard time identifying it apart from the first IE window. I can't find something that is different between the 2 other than the random title. Class, instance are the same, both visible, etc.

I know handles are different, but how do I use WinGetHandle since it uses the same identifiers (class, title, instance)?

Is there a way to say "identify/use IE that is NOT [title=FIRST]"?

A couple things I tried:

WinSetState("[ACTIVE]", "",@SW_MAXIMIZE) ; not really accurate
WinSetState("Explorer", "Done",@SW_MAXIMIZE) ; not accurate, sometimes closes FIRST window

Any help appreciated, TIA.

Share this post


Link to post
Share on other sites



No, your first four lines do not work as shown because you use $oIE before setting it.

Class and title might be the same, but if they are then instance will not be, so all three should never be the same for WinGetHandle().

Perhaps you mean multiple tabs instead of multiple windows?

As for "IE that is NOT [title=FIRST]", you might look at "Window Titles and Text (Advanced)" in the help file and try "[CLASS:YourClass; REGEXPTITLE:YourRegExpPattern]".

:graduated:


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

#3 ·  Posted (edited)

Thanks for pointing out all of that information. My apologies for not making my example perfectly proper.

Please realize that this is part of larger code but I am trying to display the salient parts for this question instead of my entire code.

I have fixed it to address your comment of no it doesn't work. Yes, it does. And that's not the point.

#include <IE.au3> ;so IE functions will work
Opt("WinTitleMatchMode", 2) ;so partial titles will be found instead of exact ones
$oIE = _IECreate ("http://somewebsite.com") ;assume title is "First"
_IELinkClickByText ($oIE, "click me")
WinSetState("Explorer", "", @SW_MAXIMIZE) ; simple example of something that affects a window
Moving on. You tell me that if class & title are the same, instance will be different. Agreed.

You also seem to think I don't know the difference between tabs & windows. Allow me to draw you a picture in order to better illustrate my point. In the attachment you can see 2 separate windows of IE7, both with an instance of 1. This was the first thing I checked. Additionally, I state that my issue is that one window will have a random, unknown title. So instance will NEVER be different since not everything else is the same. So I reiterate my question: In the example attachment, how do I differentiate between the 2 windows of IE, without using TITLE?

Regarding the [CLASS:YourClass; REGEXPTITLE:YourRegExpPattern]", I have to figure out how to use StringRegExp and exclude the window I don't want to affect. I don't know exactly how to do this. I'll read up on it. Thanks.

post-56851-0-48298000-1291068531_thumb.j

Edited by Viscouse

Share this post


Link to post
Share on other sites

Yeah, REGEXPTITLE is great for positive finding of a pattern, but not good for negative findings of the absence of a pattern. You could go this route:

#include <IE.au3>

Global $oIE, $hWnd, $sTitle, $aURLs[3] = ["http://www.google.com", "http://www.autoitscript.com", "http://news.google.com"]

For $n = 0 To UBound($aURLs) - 1
    $oIE = _IECreate($aURLs[$n])
    $hWnd = _IEPropertyGet($oIE, "hwnd")
    $sTitle = WinGetTitle($hWnd, "")
    ConsoleWrite("Created IE instance:  hWnd = " & $hWnd & "; Title = " & $sTitle & @LF)
Next

$aWinList = WinList("[CLASS:IEFrame]", "")
ConsoleWrite(@LF & "The following existing IE window titles DO NOT contain 'AutoIt':" & @LF)
For $n = 1 To $aWinList[0][0]
    If Not StringInStr($aWinList[$n][0], "AutoIt") Then
        ConsoleWrite("hWnd = " & $aWinList[$n][1] & "; Title = " & $aWinList[$n][0] & @LF)
    EndIf
Next

:graduated:


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

Groovy.

Looped(WinList + NOT StringInStr) = Solutiony goodness.

Thanks for the assist PsaltyDS. I appreciate it!

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