Jump to content

How do I determine which IE browser window is on top?


Capel
 Share

Recommended Posts

If I have multiple IE browser windows with similar titles, how do I determine which one is on top?

I'm trying to iterate over all the open browser windows, but the code below shows 2 instances of each browser. They have different handles. This is strange...

$lstViewers = WinList($sTitle)
For $i = 1 to $lstViewers[0][0]
  ConsoleWrite("Title=" & $lstViewers[$i][0] & "  Handle=" & $lstViewers[$i][1] & @CRLF)
Next
Link to comment
Share on other sites

Found this poking around in the Help File under "Window Titles and Text (Advanced)"

Advanced Window Descriptions

A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:

TITLE - Window title

CLASS - The internal window classname

REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2)

REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2)

LAST - Last window used in a previous AutoIt command

ACTIVE - Currently active window

X \ Y \ W \ H - The position and size of a window

INSTANCE - The 1-based instance when all given properties match

WinClose("[ACTIVE]", "")

This should help you.

Link to comment
Share on other sites

Well I dont know what a z order is, but this gives me the active one, if indeed one is active.

The sleep is just there, so I could activate one of them.

#include <Array.au3>

$title = "[Class:IEFrame]"
$awin = WinList($title)

Sleep(2000)

For $i = 1 To $awin[0][0]
    $state = WinGetState($awin[$i][0])
    If BitAND($state, 8) Then
        MsgBox(0,"",$awin[$i][0] & " Is active" & @LF & "Handle = " & $awin[$i][1])
    EndIf
Next

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Z-order is an ordering of overlapping two-dimensional objects, such as windows in a graphical user interface (GUI). In my case, the IE window I need to interact with may not be the currently active window (there could be a windows forms app on top), but I want to interact with the IE browser that is on top of all the other IE browser windows.

Link to comment
Share on other sites

Here being shown.

#include <Array.au3>
#include <IE.au3>
$title = "[Class:IEFrame]"
_IECreate("http://uk.yahoo.com/")
_IECreate("http://www.bing.com/")
_IECreate("http://www.google.com/")

$awin = WinList($title)
_ArrayDisplay($awin)
WinActivate($awin[3][0])
$awin = WinList($title)
_ArrayDisplay($awin)
$awin = WinList($title)
WinActivate($awin[2][0])
_ArrayDisplay($awin)
$awin = WinList($title)
WinActivate($awin[1][0])
_ArrayDisplay($awin)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...