' ---------------------------------------------------------- ' Script de test d'utilisation de formulaire ' à l'aide de Internet Explorer ' ' JC BELLAMY © 2001 ' ---------------------------------------------------------- Dim shell, oIE Set shell = WScript.CreateObject("WScript.Shell") Do While true ' Ouverture d'Internet Explorer Set oIE = WScript.CreateObject("InternetExplorer.Application", "IE_") oIE.Left = 50 oIE.Top = 100 oIE.Height = 550 oIE.Width = 550 oIE.MenuBar = 0 oIE.ToolBar = 0 oIE.StatusBar = 0 oIE.navigate GetPath() & "test.html" oIE.Visible = 2 Do While (oIE.Busy) WScript.Sleep 200 Loop shell.AppActivate "Test de formulaire avec IE" ' Attente d'action sur le bouton ou fermeture de la fenêtre On Error Resume Next Do WScript.Sleep 100 Loop While (oIE.Document.Script.CheckVal() = 0) ' Si on ferme directement IE sans passer par un bouton, ' cela provoque une erreur qui est détectée et alors ' on quitte le script If Err <> 0 Then Wscript.Echo "On a fermé IE directement" Wscript.quit end if test=oIE.Document.Script.CheckVal() If test=-1 Then CloseIE Wscript.Echo "On a appuyé sur Annuler" Wscript.quit end if Choix1=oIE.Document.TestForm.options.value Choix2=oIE.Document.TestForm.autre.value for index=0 to oIE.document.TestForm.methode.length-1 if oIE.document.TestForm.methode(index).checked then exit for end if next Wscript.Echo "On a appuyé sur le bouton " & test & VBCRLF & VBCRLF _ & "On a choisi : " & Choix1 & " et " & Choix2 & VBCRLF _ & "Case 1 : " & oIE.Document.TestForm.case1.Checked & VBCRLF _ & "Case 2 : " & oIE.Document.TestForm.case2.Checked & VBCRLF _ & "Fichier : " & oIE.Document.TestForm.fichier.value & VBCRLF _ & "Texte : " & oIE.Document.TestForm.texte.value & VBCRLF _ & "Mot de passe : " & oIE.Document.TestForm.pwd.value & VBCRLF _ & "Méthode : " & oIE.document.TestForm.methode(index).value CloseIE loop '------------------------------------------------------------ ' Fonction de récupération du répertoire courant Function GetPath() Dim path path = WScript.ScriptFullName GetPath = Left(path, InStrRev(path, "\")) End Function '------------------------------------------------------------ ' Fermeture d'Internet Explorer Sub CloseIE oIE.Quit Set oIE = Nothing End Sub '------------------------------------------------------------