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

Windows Discussion :

HTA/WSH : Ouvrir un fichier, et envoyer le contenu ligne à ligne dans une fenêtre avec iframe


Sujet :

Windows

  1. #1
    Membre actif
    Homme Profil pro
    Consultant communication & réseaux
    Inscrit en
    Octobre 2013
    Messages
    86
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Consultant communication & réseaux
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Octobre 2013
    Messages : 86
    Points : 206
    Points
    206
    Par défaut HTA/WSH : Ouvrir un fichier, et envoyer le contenu ligne à ligne dans une fenêtre avec iframe
    Bonjour

    Problématique : HTA/WSH : Ouvrir un fichier, et envoyer le contenu ligne à ligne dans une fenêtre avec iframe

    Langage : HTA ou WBS ou WSH

    J'arrive désormais à ouvrir un fichier texte, lire son contenu et l'afficher dans une textbox ou multibox.

    Je voudrais ensuite envoyer le contenu du fichier dans une page web dans laquelle il y a une iframe (je connais le nom via le code source), et valider ligne à ligne.

    J'arrive avec sendkeys à me déplacer dans l'iframe donnée, mais c'est très lourd et assez capricieux quand à l'exactitude du ciblage.

    Je pense que je dois passer par une boucle avec les contrôles d'I/O pour un fichier pour parser chaque ligne, mais c'est comment envoyer les lignes dans l'iframe qui me pose problème.

    Si quelqu'un a une idée ?

    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
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    <HTA:APPLICATION 
    SCROLL="no"
    BORDER="thin"
    CAPTION="yes"
    ICON="favicon.ICO"
    CONTEXTMENU="no"
    SELECTION="yes"
    WINDOWSTATE="normal"
    SINGLEINSTANCE="yes"
    SYSMENU="yes"
    >
    <html>
    <TITLE>Gestion_OTR</TITLE>
    <script language='jscript'>
    function init(){
    self.resizeTo(900,900);
    fso=new ActiveXObject("Scripting.FileSystemObject");
    hname=document.getElementById("BTfn");
    hedit=document.getElementById("EDIT");
    }
    
    function BTo(){
    hfile = fso.OpenTextFile(hname.value, 1, false, 0);
    hedit.innerText = hfile.ReadAll();
    hfile.Close();
    }
    
    function BTs(data){
    hfile = fso.OpenTextFile(hname.value, 2, false, 0);
    hfile.Write(hedit.innerText);
    hfile.Close();
    }
    </script>
    <script language="vbscript">
    Sub Check
    Set MonShell=CreateObject("wscript.Shell")
    MonShell.Run "http://xxx.xxx.xxx.xxx/html/MMC/MMC_index.php"
    'Attente que la page soit ouverte avec l'invite de session puis valider le bouton OK
    WaitSeconds 1
    MonShell.AppActivate "Connexion à"
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{ENTER}", False 'RETURN
    WaitSeconds 3
    'Attendre que la connexion soit établie et on positionne la fenêtre sur tout l'écran
    MonShell.AppActivate "VA06 "
    MonShell.SendKeys "%", False 'ALT KEY
    MonShell.SendKeys " ", False 'SPACE KEY
    MonShell.SendKeys "{DOWN}", False 'FLECHE BAS
    MonShell.SendKeys "{DOWN}", False 'FLECHE BAS
    MonShell.SendKeys "{ENTER}", False 'RETURN
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "{TAB}", False 'TAB
    MonShell.SendKeys "Commandes issues du fichier texte à terme;", False 'RETURN
    MonShell.SendKeys "{ENTER}", False 'RETURN
    End Sub
    
    Sub WaitSeconds (intNumSecs) 
        ' Because WScript.Sleep () is not available in HTA 
        ' scripts, invoke a VBScript file to do the waiting. 
     
        Dim strScriptFile, strCommand, intRetcode, objWS 
     
        If intNumSecs <= 0 Then Exit Sub 
     
        Set objWS = CreateObject ("WScript.Shell") 
     
        strScriptFile = "%temp%\wait" & intNumSecs & "seconds.vbs" 
     
        strCommand = "cmd /c ""echo WScript.Sleep " & intNumSecs * 1000 & " >" & strScriptFile & _ 
                    "&start /wait """" wscript.exe " & strScriptFile & """" 
     
        intRetCode = objWS.Run (strCommand, 0, True) 
     
        If intRetCode = 0 Then Exit Sub 
     
        LogLine "ERROR " & CStr (intRetCode) & " DURING WAITSECONDS PROCEDURE" 
    End Sub 
    
    </script>
    
    <script>
    
    </script>
    <body onload="init();" bgColor=#E80000>
    <input id='BTfn' type=file Value='search'/>
    <input id='BTo' onclick='BTo();' type=button value='Ouvrir' />
    <input id='BTs' onclick='BTs();' type=button value="Sauver" />
    <B>&nbsp&nbspChargement de l'OTR</B>
    <DIV>
    <textarea id="EDIT" rows="40" cols="104" name="EDIT" wrap="hard">
    </textarea>
    </DIV>
    <P></P>
    <input id='Check' onclick='Check()' type=button value="Checker OTR" />
    <input id='Check' onclick='Frame();' type=button value="Frame" />
    </body>
    </html>

    Merci

  2. #2
    Membre éprouvé Avatar de gretch
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Avril 2006
    Messages
    1 165
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Avril 2006
    Messages : 1 165
    Points : 1 250
    Points
    1 250
    Par défaut
    je ne sait pas si la solution te convient mais perso,
    j'aurais modifier un autre doc html que j'aurais "charger" dans l'iframe dans un second temps... est ce la bonne solution... pas sure.

Discussions similaires

  1. Ouvrir un fichier PDF dans une fenêtre delphi
    Par Wilco dans le forum Langage
    Réponses: 2
    Dernier message: 24/02/2021, 08h31
  2. [XL-2010] macro pour ouvrir x fichier selectionner des col et les coller dans une feuille xl
    Par grainedechipie dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 10/02/2015, 09h46
  3. Ouvrir un fichier excel à partir du contenu d'une cellule
    Par Lou12 dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 07/07/2006, 13h28
  4. Comment envoyer du texte dans une fenêtre spéciale ?
    Par Coussati dans le forum Composants VCL
    Réponses: 11
    Dernier message: 25/10/2005, 09h00
  5. Ajout de 'raccourcis' dans une fenêtre standard 'Ouvrir'
    Par Laurent Dardenne dans le forum Windows
    Réponses: 4
    Dernier message: 08/03/2005, 18h53

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