[Func] _IEFrameGetObjById !

Partagez des fonctions et des UDF AutoIt.
Règles du forum
.
Répondre
Avatar du membre
DavidRobin33
Niveau 1
Niveau 1
Messages : 11
Enregistré le : jeu. 28 nov. 2013 16:40
Localisation : BORDEAUX
Status : Hors ligne

[Func] _IEFrameGetObjById !

#1

Message par DavidRobin33 »

Bonjour,
Depuis que je suis passé en v3.3.10.2, mes scripts avec _IEFrameGetObjByName ne fonctionnent plus. Après quelques heures de recherche inutile à essayer de comprendre ce qui n'allait pas :( , j'ai trouvé la solution sur le forum anglais que je vous transmets afin d'éviter de perdre du temps à votre tour !

La nouvelle version de IE.au3 ne permet plus de rechercher par ID ou par nom mais uniquement par nom.
Donc si vous ne possédez que l'ID (comme dans mon cas), voici les 2 solutions possibles à ce jour :
- soit utiliser _IEFrameGetCollection comme alternative (solution que je n'ai pas retenu) http://www.autoitscript.com/forum/topic ... ?p=1150358
- soit utiliser _IEFrameGetObjByID qui fonctionne parfaitement http://www.autoitscript.com/forum/topic ... ?p=1038343

Code : Tout sélectionner

#include "WinAPIError.au3"

; #FUNCTION# ====================================================================================================================
; Name...........: _IEFrameGetObjById
; Description ...: Returns an object reference to a Frame by ID
; Parameters ....: $o_object - Object variable of an InternetExplorer.Application, Window or Frame object
; $s_id - ID of the Frame you wish to match
; Return values .: On Success - Returns an object variable pointing to the Window object in a Frame, @EXTENDED = Frame count
;                On Failure - Returns 0 and sets @ERROR
; @ERROR - 0 ($_IEStatus_Success) = No Error
; - 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
; - 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
; - 7 ($_IEStatus_NoMatch) = No Match
; @Extended - Contains invalid parameter number
; Origional Author ........: Dale Hohm
; Adapted By ..............: Orrin Gradwell
; ===============================================================================================================================
Func _IEFrameGetObjById(ByRef $o_object, $s_id)
If Not IsObj($o_object) Then
__IEErrorNotify("Error", "_IEFrameGetObjById", "$_IEStatus_InvalidDataType")
Return SetError($_IEStatus_InvalidDataType, 1, 0)
EndIf
;
Local $oTemp, $oFrames

If Not __IEIsObjType($o_object, "browserdom") Then
__IEErrorNotify("Error", "_IEFrameGetObjById", "$_IEStatus_InvalidObjectType")
Return SetError($_IEStatus_InvalidObjectType, 1, 0)
EndIf

If __IEIsObjType($o_object, "document") Then
$oTemp = $o_object.parentWindow
Else
$oTemp = $o_object.document.parentWindow
EndIf

If _IEIsFrameSet($oTemp) Then
$oFrames = _IETagNameGetCollection($oTemp, "frame")
Else
$oFrames = _IETagNameGetCollection($oTemp, "iframe")
EndIf

If $oFrames.length Then
For $oFrame In $oFrames
If $oFrame.id = $s_id Then Return SetError($_IEStatus_Success, 0, $oTemp.frames($s_id))
Next
__IEErrorNotify("Warning", "_IEFrameGetObjById", "$_IEStatus_NoMatch", "No frames matching Id")
Return SetError($_IEStatus_NoMatch, 2, 0)
Else
__IEErrorNotify("Warning", "_IEFrameGetObjById", "$_IEStatus_NoMatch", "No Frames found")
Return SetError($_IEStatus_NoMatch, 2, 0)
EndIf
EndFunc ;==>_IEFrameGetObjById
 
Voilà,
David
Répondre