[Func] Attendre un objet IE

Partagez des fonctions et des UDF AutoIt.
Règles du forum
.
Répondre
tioxine
Niveau 3
Niveau 3
Messages : 39
Enregistré le : sam. 14 janv. 2012 17:00
Status : Hors ligne

[Func] Attendre un objet IE

#1

Message par tioxine »

L'idée est d'attendre qu'un objet précis soit valide avant de l'utiliser
Ceci évite des erreurs lors de la manipulation de certains objets , erreurs dues à l'asynchronisme de certaine tâches
Ne fonctionne qu'avec l'udf IE

Code : Tout sélectionner

 #FUNCTION#===============================================================
; Name...........: _IEAFWaitObjet
; Description ...: Attendre un objet
; Syntax ........: _IEAFWaitObjet($pHandle, $pObj, $pMeth, $pTimer)
; Parameters ....: $pHandle  - Le handle du parent (Voir documentation associée à la méthode $pMeth)
;                  $pObj     - L'objet (Voir documentation associée à la méthode $pMeth)
;                  $pMeth    - La méthode à utiliser pour obtenir l'objet
;                  $pTimer   - Max attente en secondes
; Return values .: On Success - L'objet
;                  On Failure - -1
; Error values ..: 0 si OK, Le code erreur sinon
; Author         : 
; Version du     : V1.0 du 07/03/2013
;   Création
; ========================================================================
Func _IEAFWaitObjet ($pHandle, $pObj, $pMeth, $pTimer)
    Local $objet
    Local $xi = 0
    Local $erreur = 1

    While($erreur <> 0 And $xi < $pTimer)
        Switch $pMeth
            Case "_IEFormGetObjByName"
                ; Récup property
                $objet = _IEFormGetObjByName($pHandle, $pObj)
            Case "_IEGetObjByName"
                ; Recup des forms
                $objet = _IEGetObjByName($pHandle, $pObj)
            Case "_IEFormElementGetObjByName"
                ; récup objet par name
                $objet = _IEFormElementGetObjByName($pHandle, $pObj)
            Case "_IEFormElementOptionSelect"
                ; Modif selection
                $objet = _IEFormElementOptionSelect($pHandle, $pObj)
            Case "_IEGetObjById"
                ; Récup Id
                $objet = _IEGetObjById($pHandle, $pObj)
            Case "_IEPropertyGet"
                ; Récup property
                $objet = _IEPropertyGet($pHandle, $pObj)
            Case Else
                $erreur = -1
                $xi = $pTimer
        EndSwitch
        $erreur = @error
        $xi = $xi + 1
        Sleep(1000)
    WEnd
    If ($erreur <> 0) Then
        SetError($erreur)
        $objet = -1
    EndIf
    Return $objet
EndFunc
 
Répondre