Page 1 sur 1

[..] _IEFormElementSetValue sans effet

Posté : dim. 15 mars 2015 18:46
par blof
Bonjour,

Je cherche à remplir le champs d'un formulaire :

Code : Tout sélectionner

#include <IE.au3>

$oIE = _IECreate("http://localhost/essai/au3_form.html")

$oForm = _IEFormGetObjByName($oIE, "au3_form")
$oText = _IEFormElementGetObjByName($oForm, "au3_input")

_IEFormElementSetValue($oText, "Hey! This works!")
;_IEFormSubmit($oForm)
 
Le fichier au3_form.html :

Code : Tout sélectionner

<html>
<head>
<title>autoit</title>
</head>
<body>
<form name="au3_form" action="au3_action.php" method="post">
<input name="au3_input" type="text" size="30" maxlength="30" value="abc">
<input name="envoi" type="submit" value=" Envoyer ">
</form>
</body>
</html>
 
La page s'ouvre bien, pas de message d'erreur, mais le champs de saisie ne se met pas à jour (il reste à "abc")

Si la réponse est évidente je suis désolé.
(j'ai fait des recherches mais sans doute pas avec les bons mots clés)

J'utilise IE11.

Merci pour votre aide

Re: [..] _IEFormElementSetValue sans effet

Posté : dim. 15 mars 2015 19:01
par mikell
Pour moi ça marche, mais je n'ai que IE8...

Code : Tout sélectionner

#include <IE.au3>
$oIE = _IECreate("file:///" & @desktopdir & "/au3_form.html")
$oForm = _IEFormGetObjByName($oIE, "au3_form")
$oText = _IEFormElementGetObjByName($oForm, "au3_input")
_IEFormElementSetValue($oText, "Hey! This works!")

Re: [..] _IEFormElementSetValue sans effet

Posté : dim. 15 mars 2015 19:18
par blof
mikell, merci d'avoir testé ...

Ce qui est étrange, c'est que l'exemple de l'aide fonctionne :

Code : Tout sélectionner

; *******************************************************
; Example 1 - Open a browser with the form example, set the value of a text form element
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oText = _IEFormElementGetObjByName ($oForm, "textExample")
_IEFormElementSetValue ($oText, "Hey! This works!")
 

Re: [..] _IEFormElementSetValue sans effet

Posté : dim. 15 mars 2015 20:43
par orax
Voir les remarques de _IECreate.
New security in Windows Vista causes a new browser window to be created when a browser is instructed to navigate to a URL in a different security zone.
This occurs as well with the initial creation and navigation initiated with _IECreate().
The new window is a new browser instance and the previous browser object variable no longer points to it.
There are several workarounds:
1) add #RequireAdmin to your code (this is required even if the account is part of the Administrator's Group and will prompt for credentials if necessary),
2) use _IEAttach() to connect to the new browser window
3) add the target website to the Trusted Sites security zone in IE,
4) turn off "Protected Mode" in IE,
or 5) disable UAC. Care must be taken to understand the implications of disabling IE security features when accessing untrusted sites.
Tu pourrais faire un essai en ajoutant #RequireAdmin au début du script pour voir s'il y a du mieux.

Re: [..] _IEFormElementSetValue sans effet

Posté : lun. 16 mars 2015 19:58
par blof
orax, vu mon faible niveau d'anglais et mon niveau débutant/amateur en programmation j'avais zappé ce passage ...

- Donc, en ajoutant #RequireAdmin ça fonctionne bien.
(si ce n'est un message d'alerte "Voulez-vous autoriser le programme suivant ... à apporter des modifs à cet ordinateur", mais c'est normal)

- Pour le point 3, http://localhost était déjà dans les sites de confiance.

- Ensuite j'ai bricolé dans les options internet qui concernent la sécurité ...
... et c'est là que le drame est arrivé.

Je n'arrive plus à lancer mon WampServeur (Exception in module wampmanager.exe at 000F15A0)

Je vais d'abord essayer de réparer ça avant de revenir à AutoIt.
Je repasserai vous voir quand ça sera fait ...

En tout cas, merci encore à tous pour votre aide.

à +

Re: [..] _IEFormElementSetValue sans effet

Posté : lun. 16 mars 2015 21:55
par orax
Une alternative à RequireAdmin est d'utiliser _IEAttach.

Code : Tout sélectionner

#include <IE.au3>
Opt('WinTitleMatchMode', 3) ; 3 = titre exact
$titrePage = 'autoit'
ShellExecute("iexplore", "file:///" & @desktopdir & "/au3_form.html")
If Not WinWait($titrePage & ' - Internet Explorer', '', 60) Then Exit 1
$oIE = _IEAttach($titrePage)
$oForm = _IEFormGetObjByName($oIE, "au3_form")
$oText = _IEFormElementGetObjByName($oForm, "au3_input")
_IEFormElementSetValue($oText, "Hey! This works!")
Pour le drame :lol: en dernier recours il y a... outils > options internet > avancé > réinitialiser