Error: _IEAttach - HWND

  • Guten Abend AutoIt'ler ;)

    Ich habe ein kleines Problem mit "_IEAttach".

    Spoiler anzeigen
    [autoit]


    $oIe = Attach()

    [/autoit] [autoit][/autoit] [autoit]

    Func Attach()
    $Check = 0
    Do
    $IePid = ProcessExists("iexplore.exe")
    If $IePid Then
    $oIe = _IEAttach(GetWinHandleByPID($IePid), "HWND")
    If $oIe Then $Check = 1
    EndIf
    Until $Check
    Return ($oIe)
    EndFunc ;==>Attach

    [/autoit] [autoit][/autoit] [autoit]

    Func GetWinHandleByPID($PID)
    $wList = WinList()
    For $i = 1 To $wList[0][0]
    If IsVisible($wList[$i][1]) Then
    If WinGetProcess($wList[$i][0]) = $PID Then
    Return ($wList[$i][1])
    EndIf
    EndIf
    Next
    Return (0)
    EndFunc ;==>GetWinHandleByPID

    [/autoit] [autoit][/autoit] [autoit]

    Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
    Return 1
    Else
    Return 0
    EndIf
    EndFunc ;==>IsVisible

    [/autoit]

    Immer wenn ich dieses Script ausführe, bekomme ich folgenden Fehler:

    Code
    ==> The requested action with this object has failed.:
    Return HWnd($o_object.HWnd())
    Return HWnd($o_object.HWnd()^ ERROR

    Ich habe auch schon direkt WinGetHandle mit meiner etwas frieseligeren "WinGetHandleByPID" Version verglichen: Beides das gleiche Ergebnis. Also kann es am Handle eig. nicht liegen.

    Wüsste vllt jemand Rat?

    Vielen Dank im Voraus, LG,

    Lenny

    Jaja, Moo does the Cow!

  • Probier mal so:

    Spoiler anzeigen
    [autoit]

    #include <IE.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $ObjectsIE = Attach()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($ObjectsIE) - 1
    ConsoleWrite('! ' & _IEPropertyGet($ObjectsIE[$i], "locationurl") & @CRLF)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Func Attach()
    Local $aWintitle, $aoIE[1], $iCount = 0
    Local $aPID = ProcessList("iexplore.exe")
    For $i = 1 To $aPID[0][0]
    $aWintitle = _PID2WinTitle($aPID[$i][1])
    For $j = 1 To $aWintitle[0]
    If StringInStr($aWintitle[$j], 'Windows Internet Explorer') > 0 Then
    $iCount += 1
    ReDim $aoIE[$iCount]
    $aoIE[$iCount - 1] = _IEAttach($aWintitle[$j], 'WindowTitle')
    EndIf
    Next
    Next
    Return $aoIE
    EndFunc ;==>Attach

    [/autoit] [autoit][/autoit] [autoit]

    Func _PID2WinTitle($pid)
    ;funkey
    Local $aFenstertitel[1] = [0], $Liste = WinList()
    For $i = 1 To $Liste[0][0]
    If $pid = WinGetProcess($Liste[$i][0]) Then
    ReDim $aFenstertitel[$aFenstertitel[0] + 2]
    $aFenstertitel[0] += 1
    $aFenstertitel[$aFenstertitel[0]] = $Liste[$i][0]
    EndIf
    Next
    Return $aFenstertitel
    EndFunc ;==>_PID2WinTitle

    [/autoit]