IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

[VB Script]InputBox () - Comment masquer les données saisies


Sujet :

VBScript

  1. #1
    Candidat au Club
    Inscrit en
    Avril 2004
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 6
    Points : 2
    Points
    2
    Par défaut [VB Script]InputBox () - Comment masquer les données saisies
    Bonjour à tous,

    J'utilise la fonction InputBox() pour récupérer les données saisies par l'utilisateur. Les données saisies étant des mots de passe, j'aimerais bien les masquer. Comment faire ?
    Y'a-t-il un paramètre spécifique de la fonction InputBox() à modifier ou aurait-il une autre fonction VBS plus appropriée.

    Merci.

  2. #2
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Bonjour,

    A ma connaissance : NON !

    Après, c'est de la bidouille ...

  3. #3
    Candidat au Club
    Inscrit en
    Avril 2004
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 6
    Points : 2
    Points
    2
    Par défaut
    Quelle bidouille ?

  4. #4
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Tu peux, par exemple, créer une instance de Internet Explorer, puis créer un objet de type password, des boutons, etc...

    Si tu veux plus d'infos, pas de pb !

    A+

  5. #5
    Candidat au Club
    Inscrit en
    Avril 2004
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 6
    Points : 2
    Points
    2
    Par défaut
    Bjr,

    Je n'utilise pas un formulaire pour la saisie des données. Je ne fais pas de développement Web. Il s'agit d'un script pour automatiser des tâches d'administration Systèmes. J'ai donc des fichiers .vbs et .wsf dans lesquels j'ai défini des instructions.
    Pour l'exécution, j'utilise la commande : cscript //job:...
    La fonction inputBox() entraîne l'ouverture d'une boîte de dialogue offrant un champ de saisie. Je recherche donc un moyen pour masquer les informations saisies.

    Merci de m'aider.

  6. #6
    Candidat au Club
    Inscrit en
    Avril 2004
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 6
    Points : 2
    Points
    2
    Par défaut
    Je débute dans le développement VBS. Comment créer une instance de IE et tout ce qui s'en suit ?
    Est-ce que j'aurais recours à du code ASP ?

    Merci.

  7. #7
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Voila un script VBS qui utilise une instance de IE :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
     
       Set IE = CreateObject("InternetExplorer.Application")
     
       With IE
          .left=200
          .top=200
          .height=300
          .width=500
          .menubar=0
          .toolbar=0
          .statusBar=0
          .navigate "About:Blank"
          .visible=1
       End With
     
       ' Attendre la fin du chargement de IE
       Do while IE.busy
       loop
     
       With IE.document
          .Open
          .WriteLn "<HTML><HEAD>"
          .WriteLn "<TITLE>HTML dynamique</TITLE></HEAD>"
          .WriteLn "<BODY>"
          .WriteLn "<P align=center>"
          .WriteLn "<imput type=password name=txtPwd>"
          .WriteLn "</p>"
          .WriteLn "</BODY>"
          .WriteLn "</HTML>"
          .Close
       End With
    end if
    Set IE = Nothing
    WScript.Quit(0)

  8. #8
    Candidat au Club
    Inscrit en
    Avril 2004
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 6
    Points : 2
    Points
    2
    Par défaut
    Comment récupérer après un clic sur le bouton OK du formulaire, le password dans la suite du programme VBS ?

    Merci.

  9. #9
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Bon, un exemple complet

    Fichier PROG.VBS

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
     
     
    Option Explicit
     
    Dim oIE      ' declare variables
    Dim path
    Dim Title
    Dim Text2
    Dim name, age, password, printer, screen, remark
     
    Title = "WSH sample form input - by G. Born"
    Text2 = "You entered:" + vbCRLF
     
    ' *** get script path -> because form (HTML file)
    ' *** must be in the same folder!!!
    path = WScript.ScriptFullName
    path = Left(path, InstrRev(path, "\"))
     
    ' *** launch Internet Explorer ***
    Set oIE = WScript.CreateObject("InternetExplorer.Application")
      oIE.left=50             ' window position
      oIE.top = 100           ' and other properties
      oIE.height = 380
      oIE.width = 450
      oIE.menubar = 0         ' no menu
      oIE.toolbar = 0
      oIE.statusbar = 0
    ' commented out, because it causes a corrupted window  
    '  oIE.resizable = 0      ' disable resizing
      oIE.navigate path + "Form1.htm"  ' Form
      oIE.visible = 1         ' keep visible
     
    ' Important: wait till MSIE is ready
      Do While (oIE.Busy)      
      Loop
     
    ' Wait till the user clicks the OK button
    ' Use the CheckVal function
    ' Attention: Thanks to a note from M. Harris, we can make 
    ' the script a bit more fool proof. We need to catch the case 
    ' that the user closes the form without clicking the OK button.
     On Error Resume Next  
     Do                     ' Wait till OK button is clicked
     Loop While (oIE.document.script.CheckVal()=0)
     
    ' If an error occur, because the form is closed, quit the
    ' script
     If err <> 0 Then
      WScript.Echo "Sorry, a run-time error occured during checking" & _
                   " the OK button " & vbCRLF & _
                   "Error: " & err.number & " " & _
                   "I guess the form was getting closed..."
      WScript.Quit        ' end script
     End if
     On Error Goto 0    ' switch error handling off 
     
    ' User has clicked the OK button, retrieve the values
     name = "Name: " & oIE.Document.ValidForm.fName.Value
     age = "Age: " & oIE.Document.ValidForm.fAge.Value
     password = "Password: " & oIE.Document.ValidForm.fPassw.Value
     printer = "Printer: " & oIE.Document.ValidForm.fPrinter.Value _
               & " Status: " & oIE.Document.ValidForm.fPrinter.Checked
     screen = "Screen: " & oIE.Document.ValidForm.fScreen.Value  _
               & " Status: " & oIE.Document.ValidForm.fScreen.Checked
     remark = "Printer: " & oIE.Document.ValidForm.fRemark.Value
     MsgBox Text2 + vbCRLF + name + vbCRLF + _
            age & vbCRLF & password & vbCRLF & _
            printer & vbCRLF & screen & vbCRLF & _
            remark _
            , vbOKOnly + vbInformation, Title
     
     oIE.Quit()             ' close Internet Explorer
     Set oIE = Nothing      ' reset object variable 
     
     WScript.Quit()            ' Ready
    ' End
    Fichier FORM1.HTM
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
     
    Sub window_onload()
    ' Here we may initialize the form
     Set TheForm = Document.ValidForm
     TheForm.fName.Value="" 
     ready = 0     ' User input not ready
    End Sub
     
    Public Function CheckVal ()
    ' This is called from the host to check whether
    ' the user has clicked the OK-button
     CheckVal = ready
    End function
     
    '-->
    </script>
     
    <h3>Form</h3>
     
    <hr>
     
    <form name="ValidForm">
        <p>Name:&nbsp;&nbsp;<input type="text" size="5" name="fName">&nbsp;
        Age:     <input type="text" size="3" name="fAge"><br>
        Password:&nbsp; <input type="password" Size="12" Maxlength="8" name="fPassw">
        &nbsp; &nbsp;   <input type="button" name="Button1" value="OK"><br>
        <input type="checkbox" name="fPrinter" value="1" CHECKED>Printer &nbsp;
        <input type="checkbox" name="fScreen" value="2">Screen<br>
        Remarks:<br> <TEXTAREA Cols="40" ROWS="5" name="fRemark"></TEXTAREA></p>
    </form>
    </body>
    </html>

  10. #10
    Candidat au Club
    Inscrit en
    Avril 2004
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 6
    Points : 2
    Points
    2
    Par défaut [resolu][VB Script]InputBox () - Comment masquer les données
    Merci pour le code. Il n'était pas complet, il manquait qques instructions. Et il fallait ajuster certaines choses. Ca marche bien maintenant.

    Le pb est résolu.
    Merci encore.

  11. #11
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 69
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Il faudrait que tu mettes le tag RESOLU.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 13/02/2015, 11h43
  2. Réponses: 1
    Dernier message: 02/05/2010, 10h26
  3. Réponses: 2
    Dernier message: 18/08/2009, 10h19
  4. Réponses: 3
    Dernier message: 05/09/2008, 07h41
  5. Comment masquer les erreurs de script dans un WebBrowser ?
    Par mont5piques dans le forum Web & réseau
    Réponses: 2
    Dernier message: 11/05/2008, 17h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo