Jump to content
Sign in to follow this  
Gladson

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

Recommended Posts

Gladson

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?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.