Bonjour,
jguinch : Oui, tu as raison, à force de chercher ce qui ne va dans mon code je trouve des erreurs là où il n'y en a pas. Autant pour moi.
Plus le temps passe et plus je me dis que ce doit être tellement énorme que je ne vois pas le truc qui coince...
lesolutionneur :
voici un premier exemple très simple : je veux lancer une recherche sur le site autoitscript.com :
Code : Tout sélectionner
#include <IE.au3>
#include <MsgBoxConstants.au3>
Local $oIE = _IECreate("http://www.autoitscript.com")
Local $oForms = _IEFormGetCollection($oIE)
Local $iNumForms = @extended
MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & $iNumForms & " forms on this page")
Local $oForm
For $i = 0 To $iNumForms - 1
$oForm = _IEFormGetCollection($oIE, $i)
MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.id)
Next
Local $oField_search = _IEFormElementGetObjByName($oForms, "s")
_IEFormElementSetValue($oField_search, "documentation autoit")
_IEFormSubmit($oForms)
;Send("{ENTER}")
L'id du form s'affiche bien, donc il l'a bien trouvé.
Mais impossible d'alimenter la zone de recherche ni de lancer la recherche par "submit" ou "send"
Le vrai prog que je souhaite faire c'est le suivant :
Code : Tout sélectionner
#include <IE.au3>
#include <MsgBoxConstants.au3>
Dim $url_enter = "mon_url.html"
Dim $username_ID = "username"
Dim $username_value = "toto"
Dim $pwd_ID = "password"
Dim $pwd_value = "tutu"
Local $oIE = _IECreate($url_enter)
Local $oForms = _IEFormGetCollection($oIE)
Local $oField_username = _IEFormElementGetObjByName($oForms, $username_ID)
_IEFormElementSetValue($oField_username, $username_value)
Local $oField_pwd = _IEFormElementGetObjByName($oForms,$pwd_ID)
_IEFormElementSetValue($oField_pwd, $pwd_value)
Local $oButton = _IEFormElementGetObjByName($oForms, "B1")
_IEAction($oButton, "click")
MsgBox(0,"Finish", "Process ended")
Le code source de la page :
Code : Tout sélectionner
<!-- Entrust TruePass 8.1 -->
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>User Authentication - Entrust Desktop Security Store User</title>
</head>
<script language="JavaScript">
function browse()
{
apiAccess.entrustTruePassClientAPI.entrustTruePassToolkitShowLoadFileDialog("operationID", "entrustTruePassShowFileDialogEventListener", "parent.entrustTruePassGuiFrame", "Select a profile to log in to", ".epf");
}
// Callback function for file dialog display -- called once the user has selected a file or cancelled the dialog
function entrustTruePassShowFileDialogEventListener(statusCode, operationID, fileName)
{
if (statusCode == 0){
document.entrustform.username.value = fileName;
}
}
</script>
<body>
<!-- This is a check if the Entrust TruePass API is present.
This case (when an input page is loaded but the API is missing) indicates
a undefined situation within the TruePassSample pages.
The index page of the TruePassSample will be loaded to the top to get a
proper state of the TruePassSample. -->
<script language="JavaScript">
if (parent.multiDomainConfiguration == "PRIMARYSITE") {
apiAccess = parent;
}
else {
apiAccess = top;
}
if (!(apiAccess.entrustTruePassClientAPI)) {
apiAccess.document.location = "/GetAccess/ResourceList";
}
</script>
<font face="Arial, Helvetica" size="2">
<br>
<STRONG>Aviso a los usuarios con algún tipo de discapacidad visual, cognitiva o motriz:</STRONG> los servicios con certificado digital no cumplen las pautas de accesibilidad, lo que puede impedir un acceso correcto a los mismos. <a href="xxxx" target="_top">(Más información)</a>
<br>
<br>
<br>
<b>Autenticación de usuarios - Certificado SILCON</b>
<br>
<br>
Por favor, seleccione el archivo .epf que contiene su certificado SILCON e introduzca la contraseña correspondiente a este certificado.
<!--
Most TruePass related forms contain sensitive data such as usernames and passwords.
To prevent such sensitive data from being sent over to the webserver (and consequently
showing up in the Web server's log file), steps must be taken to indicate to the browser
that it should not submit the form data to the server - instead, the onSubmit Javascript
handler must be used to call into the TruePass applet for processing the form data.
The following security guidelines are recommended for all TruePass forms:
1. The internal default "onSubmit" EventHandler of the Web browser automatically sends the
content of a form as a query string in a HTTP GET request (the form data will be sent
over the net and show up in the Web server's log file). Make sure to disable the
default "onSubmit" EventHandler under all circumstances by using the following statement:
onSubmit="entrustTruePassFunction(); return false;"
The command 'entrustTruePassFunction()' will be dispatched and 'return false' will be executed
regardless of the return value of 'entrustTruePassFunction()'.
2. Generate the form's submit button (or image) using the document.write() method of Javascript.
This prevents the form from having a submit button when Javascript is unavailable. In such
cases, the <noscript> tag can be used to indicate to the end user that Javascript is unavailable.
3. A form that has just a single HTML input type element, is submitted by the browser even if
a submit button is not present in the form. If it is necessary to have such a form, then the
HTML code for the input type should be generated using Javascript, like in step 2 above.
4. Add the ACTION="https://0.0.0.0" attribute to the form definition. This is a non-Javascript
solution which prevents the form data from leaving the end user's machine under all circumstances.
-->
<form name="entrustform" ACTION="https://0.0.0.0" onSubmit="apiAccess.entrustTruePassClientAPI.entrustTruePassAuthenticateUser(document.entrustform); return false;">
<!-- The names of the input fields must be "username", "password", "authenticationExtension"
and "storeUsernameCheckbox". The authenticationExtension and the checkbox are optional
but if they exist, the mentioned names are mandatory. -->
<table border="0">
<tr>
<td><font face="Arial, Helvetica" size="2"><b>Archivo EPF:</b></font></td>
<td><input type="text" name="username" size="38"></td>
<td><input type="button" value= "Explorar" name="browseButton" onClick="browse();" ></td>
<script language="JavaScript">
if (apiAccess.entrustTruePassClientAPI.entrustTruePassGetLastUserProfileType() == "LOCAL_EPF") {
document.entrustform.username.value= apiAccess.entrustTruePassClientAPI.entrustTruePassGetLastUser();
}
</script>
</tr>
<tr>
<td><font face="Arial, Helvetica" size="2"><b>Contraseña:</b></font></td>
<!-- AUTOCOMPLETE = "off" will turn off the password autocomplete option-->
<td><input type="password" name="password" AUTOCOMPLETE="off" value="" size="38"></td>
<!-- Set the focus to the password or the username field -->
<script>
if (document.entrustform.username.value == "") {
// Set the focus to the username field if no username was read from the cookie
document.entrustform.username.focus();
}
else {
// Set the focus to the password field if a username is present
document.entrustform.password.focus();
}
</script>
</tr>
<tr>
<td></td>
<td><input type="checkbox" checked name="storeUsernameCheckbox">
<font face="Arial,Helvetica" size="2">Recordar usuario</font></td>
</tr>
<tr>
<td>
</td>
<td>
<br>
<script>
// The button triggers the Authenticate User function from the API
document.write('<input type="submit" value="Aceptar" name="B1">');
</script>
<noscript>
<font color="red">
<br>
<b>Error: Javascript debe estar habilitado para las operaciones de TruePass</b>
<br>
</font></noscript>
<input type="reset" value="Cancelar" name="B2">
</td>
</tr>
</table>
</form>
</font>
<p>
<font face="Arial, Helvetica" size="2">
<br>
Si no dispone usted de un Certificado SILCON, consulte por favor el apartado de Certificados Digitales dentro de nuestra Sede Electrónica.
</font>
</p>
</body>
</html>
C'est un site espagnol, il est un peu expurgé de certaines données... s'il y a besoin j'envoie en MP la véritable adresse...
Je précise juste, que, ce que je veux faire est évidement légal : aider des utilisateurs qui remplissent manuellement des formulaires pour télécharger des attestations PDF.... ils en ont parfois plusieurs centaines par jours !
D'avance merci.