Jump to content

Generating a list (an array) of all currently open IE windows


Gladson
 Share

Recommended Posts

Hello,

 

I've been using AutoIt V3 for a long time but I'm struggling on creating a function to generate a list (an array) of all currently open IE windows. I need the PID, handle, url and title, this is what I've been trying:

 

#include <Array.au3>
#include <IE.au3>

Func _GetIEList()
    Local $arrayReturn[1][4] = [["PID", "HWND", "URL", "TITLE"]]

    ; Lists IE windows
    Local $listIE = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]")
    _ArrayDisplay($listIE, "IE Windows")

    Local $aProcessList = ProcessList("iexplore.exe")
    _ArrayDisplay($aProcessList, "IE Processes")

    For $i=1 To Ubound($listIE)-1
        Local $oIE_temp = _IEAttach($listIE[$i][1], "hwnd")

        If @error == 0 Then
            Local $aFill[1][4] = [[WinGetProcess($listIE[$i][1]), $listIE[$i][1], _IEPropertyGet($oIE_temp, "locationurl"), $listIE[$i][0]]]
            _ArrayAdd($arrayReturn, $aFill)
        EndIf
    Next

    Return $arrayReturn
EndFunc

Local $testReturn = _GetIEList()
_ArrayDisplay($testReturn, "Function Return")

 

I list all IE windows with WinList to get their handles and try to associate them with the PID list generated by ProcessList. However, the results are kind of strange sometimes. Not all open windows are shown on $testReturn, PIDs or handles are duplicated, it's a mess.

 

Is there any easier and more trustworthy way of generating this array with the info I need?

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