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

 C Discussion :

SendMessage & Handle de fenêtre et ses champs


Sujet :

C

  1. #1
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut SendMessage & Handle de fenêtre et ses champs
    Bonjour,

    J'ai une fenêtre à laquelle j'envoie 2 informations pour les 2 champs qui s'y trouvent.
    Je dois notamment effectuer une tabulation pour changer de champs mais je n'ai pas l'impression que cela marche. Grâce à un FindWindows je spécifie pourtant le handle de la fenêtre.

    Est ce que cela est correct ?

    SendMessage(Handle,WM_CHAR,VK_TAB,0); // touche enfoncée
    SendMessage(Handle,WM_CHAR,VK_TAB,KEYEVENTF_KEYUP); //touche relâchée

    C'est ce que j'ai lu dans le tuto de tcharles mais il ne relâche pas alors je sais pas, j'essayé les 2 sans succès

    Merci
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  2. #2
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    WM_CHAR ne va pas avec ça, il faudrait utiliser WM_KEYDOWN et WM_KEYUP.
    Ou mieux, ne pas les utiliser.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  3. #3
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Si j'ai bien compris pour simuler tab il me faut :

    SendMessage(Handle,WM_KEYDOWN,VK_TAB,0); // touche enfoncée
    SendMessage(Handle,WM_KEYUP ,VK_TAB,0); //touche relâchée

    Mais cela ne marche pas. Pourtant ça envoit bien l'information de la touché tab préssée puis relâché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
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    // BIBLIOTHEQUES ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    #include <QtGui>
    #include <windows.h>
    #include "AUTOLOG.h"
     
    // CONSTANTES //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
     
     
    // PROTOTYPES //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void InitDisplay( QPushButton *Start, QPushButton *Stop, QPushButton *Download, QLabel *PrintAuthor, QLabel *PrintVersion, QLabel *PrintTitle, QLabel *PrintID, QLabel *PrintPW, QLabel *PrintRepeat, QLabel *PrintExecutionTime, QString QID, QString QPW, QString QRepeat, char *Repeat, int X, int Y );
    void Write(HWND Handle, char *Flux, int Size);
    void ENTER( HWND Handle);
    void WAIT();
    void TAB(HWND Handle);
     
     
     
    // CLASSE FENETRE //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    MaFenetre::MaFenetre() : QWidget()
    {
     
        /* On fixe définitivement la taille de la fenêtre */
        int X=300;
        int Y=150;
        setFixedSize(X, Y);
     
        char ID[999], PW[999], Repeat[999], Timer [999];
     
          /* On récupère ces informations dans le .ini */
        GetPrivateProfileStringA("Settings",     "ID", "", ID    , 999, ".//autorun.ini");
        GetPrivateProfileStringA("Settings",     "PW", "", PW    , 999, ".//autorun.ini");
        GetPrivateProfileStringA("Settings", "REPEAT", "", Repeat, 999, ".//autorun.ini");
     
        /* Convertion en QString des ID & PW */
        QString QID     = QString(ID    );
        QString QPW     = QString(PW    );
        QString QRepeat = QString(Repeat);
     
    	/* Création des objets */
    	PrintTitle         = new QLabel(this);
        PrintID            = new QLabel(this);
        PrintPW            = new QLabel(this);
        PrintRepeat        = new QLabel(this);
        PrintExecutionTime = new QLabel(this);
        PrintAuthor        = new QLabel(this);
        PrintVersion       = new QLabel(this);
        Frame              = new QLabel(this);
     
        Start              = new QPushButton("Start"   , this);
        Stop               = new QPushButton("Quit"    , this);
        Download           = new QPushButton("Download", this);
     
        Picture            = new QPixmap("image.jpg"  );
     
        /* Initialisation de l'affichage */
        InitDisplay( Start, Stop, Download, PrintAuthor, PrintVersion, PrintTitle, PrintID, PrintPW, PrintRepeat, PrintExecutionTime, QID, QPW, QRepeat, Repeat, X, Y);
     
        Frame -> setPixmap( *Picture );
     
        /* Signaux */
    	QObject::connect(Start    , SIGNAL(clicked()) , this, SLOT( LogProcedure() ));
    	QObject::connect(Stop     , SIGNAL(clicked()) , qApp, SLOT( quit() ));
    	QObject::connect(Download , SIGNAL(clicked()) , this, SLOT( DownloadProcedure() ));
    }
     
     
    // FONCTIONS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    void InitDisplay( QPushButton *Start, QPushButton *Stop, QPushButton *Download, QLabel *PrintAuthor, QLabel *PrintVersion, QLabel *PrintTitle, QLabel *PrintID, QLabel *PrintPW, QLabel *PrintRepeat, QLabel *PrintExecutionTime, QString QID, QString QPW, QString QRepeat, char *Repeat, int X, int Y)
    {
     
        int RepeatValue        = atoi(Repeat)                  ;
        int ExecutionTime      = (int)(RepeatValue/60)         ; 
        QString QExecutionTime = QString::number(ExecutionTime);
     
        int ButtonWidth  = 60                              ;
        int ButtonHeight = 20                              ;
        int Space        = 20                              ;
        int xStart       = (X-(3*ButtonWidth+2*Space))/2   ;
        int xDownload    = xStart     + ButtonWidth + Space;
        int xStop        = xDownload  + ButtonWidth + Space; 
        int yButton      = 0.85*Y                          ;
     
        PrintTitle         -> setText("<strong><font color=\"red\">-------------AUTO LOGGER-------------</font></strong>" );
        PrintID            -> setText("<strong><small>ID</small></strong> : " + QID                                       );
        PrintPW            -> setText("<strong><small>PW</small></strong> : " + QPW                                       );
        PrintRepeat        -> setText("<strong><small>REPEAT</small></strong> : " + QRepeat                               );
        PrintExecutionTime -> setText("<strong><small>EXECUTION TIME</small></strong> : ~" + QExecutionTime +" minutes"   );
        PrintAuthor        -> setText("<small>® DARKWALL_37</small>"                                                      );
        PrintVersion       -> setText("<small>V1.05</small>"                                                              );
     
        PrintTitle         -> move( (X - PrintTitle    -> minimumSizeHint().width())/2, 0.175*Y      );
        PrintID            -> move( (X - PrintID       -> minimumSizeHint().width())/2, 0.30*Y       );
        PrintPW            -> move( (X - PrintPW       -> minimumSizeHint().width())/2, 0.40*Y       );
        PrintRepeat        -> move( (X - PrintRepeat   -> minimumSizeHint().width())/2, 0.50*Y       );
        PrintVersion       -> move( X - (PrintVersion -> minimumSizeHint().width() + 0.01*X), 0.01*Y );
        PrintExecutionTime -> move( (X - PrintExecutionTime -> minimumSizeHint().width())/2, 0.60*Y  );
        PrintAuthor        -> move( 0.01*X, 0.01*Y                                                   );
     
        Start        -> setGeometry( xStart   , yButton , ButtonWidth,  ButtonHeight ); 
        Stop         -> setGeometry( xStop    , yButton , ButtonWidth,  ButtonHeight );
        Download     -> setGeometry( xDownload, yButton , ButtonWidth,  ButtonHeight );  
    }
     
     
    void MaFenetre::DownloadProcedure()
    {
         system("start iexplore http://www.megaupload.com/?f=BMBSOTON | start iexplore http://www.sro-lottery.com ");
    }
     
    void MaFenetre::LogProcedure()
    {
     
        char ID[999], PW[999], Repeat[999]; 
     
        GetPrivateProfileStringA("Settings",     "ID", "", ID    , 999, ".//autorun.ini");
        GetPrivateProfileStringA("Settings",     "PW", "", PW    , 999, ".//autorun.ini");
        GetPrivateProfileStringA("Settings", "REPEAT", "", Repeat, 999, ".//autorun.ini");
     
        int IDSize=strlen(ID);
        int PWSize=strlen(PW);
     
        HWND Handle = FindWindowA("Notepad",NULL);
        SetForegroundWindow(Handle);
     
        WAIT();
        Write(Handle, ID, IDSize);
        TAB(Handle);
        Write(Handle, PW, PWSize);
     
        int LoopNumbers = atoi(Repeat);
        int control     = 0           ;
     
        if (Handle)
           { 
                   while ( control != LoopNumbers )
                         {
                               ENTER(Handle);
                               control++;      
                         }
           }    
    }
     
     
    void Write(HWND Handle, char *Flux, int Size)
    {
     
     
        int i=0;          
        for ( i=0 ; i<Size ; i++ )        
            {               
                   char CurrentLetter = Flux[i];                                                                                                                        
     
                   // Chiffre
     
                      if ( '0' == CurrentLetter )
                         {
                              keybd_event(0x60,0,0,0);
                               _sleep(40);
                         }
     
                 else if ( '1' == CurrentLetter )
                         {
                              keybd_event(0x61,0,0,0);
                              _sleep(40);
                         }
     
                 else if ( '2' == CurrentLetter )
                         {
                              keybd_event(0x62,0,0,0);
                              _sleep(40);
                         }
     
                 else if ( '3' == CurrentLetter )
                         {
                              keybd_event(0x63,0,0,0);
                              _sleep(40);
                         }                                   
     
                 else if ( '4' == CurrentLetter )
                         {
                             keybd_event(0x64,0,0,0);
                             _sleep(40);
                         }
     
                 else if ( '5' == CurrentLetter )
                         {
                             keybd_event(0x65,0,0,0);
                             _sleep(40);
                         }
     
                 else if ( '6' == CurrentLetter )
                         {
                             keybd_event(0x66,0,0,0);
                             _sleep(40);
                         }
     
                 else if ( '7' == CurrentLetter )
                         {
                              keybd_event(0x67,0,0,0);
                              _sleep(40);
                         }                                  
     
                 else if ( '8' == CurrentLetter)
                         {
                              keybd_event(0x68,0,0,0);
                              _sleep(40);
                         }
     
                 else if ( '9' == CurrentLetter )
                         {
                              keybd_event(0x69,0,0,0);
                              _sleep(40);
                         }
     
     
              // Caractères spéciaux
     
                 else if ( '@' == CurrentLetter )
                         {
                              keybd_event(VK_MENU,0,0,0);
                              keybd_event(VK_CONTROL,0,0,0);
                              keybd_event(0x30,0,0,0);
                              keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
                              keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
                              keybd_event(0x30,0,KEYEVENTF_KEYUP,0);
                              _sleep(50);
     
                         }
     
                 else if ( '.' == CurrentLetter )
                         {
     
                               keybd_event(VK_SHIFT,0,0,0);
                               keybd_event(0xBE,0,0,0);
                               keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
                               keybd_event(0xBE,0,KEYEVENTF_KEYUP,0);
                               _sleep(40);
                         }
     
           // Caractères usels
     
                 else    {
     
                               SendMessage(Handle,WM_KEYDOWN,VkKeyScan(Flux[i]),0);
                               _sleep(40);
                         }
           }
     
    }
     
     
    void WAIT()
    {
         _sleep(5000);
    }
     
     
    void TAB(HWND Handle)
    {
         SendMessage(Handle,WM_KEYDOWN,VK_TAB,0);
         SendMessage(Handle,WM_KEYUP  ,VK_TAB,0);  
    }
     
    void ENTER(HWND Handle)
    {
        SendMessage(Handle,WM_CHAR,VK_RETURN,0);
        _sleep(500);                          
    }
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  4. #4
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Si j'ai bien compris pour simuler tab il me faut :

    SendMessage(Handle,WM_KEYDOWN,VK_TAB,0); // touche enfoncée
    SendMessage(Handle,WM_KEYUP ,VK_TAB,0); //touche relâchée
    Perdu, il faut utiliser SendInput() comme dit dans mon lien.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  5. #5
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Je comprends pas,

    Si les keyboardevent ne marche pas avec les SendMessage mais qu'il faut utiliser les SendInput ok mais alors je lui dis comment que je veux la touche TAB par exemple ? parce que mise à part la connexion entre la valeur hexa de la touche et son VK_XXX, je vois pas comment nommer une touche. Quelque chose m'échappe.


    UINT SendInput( UINT nInputs,
    LPINPUT pInputs,
    int cbSize
    );Parameters

    nInputs
    [in] Number of structures in the pInputs array. // Nombre de structures dans le tableau pInputs
    pInputs
    [in] Pointer to an array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream.
    Pointeurs d'un tableau d'une structure de type INPUT. Chaque structure représente un évenement à être inséré dans l'entrée "courante" de la souris ou du le calvier.
    cbSize
    [in] Specifies the size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function fails.
    Return Value
    Spécifie la taille en bits de la structure d'entrée. Si cbsize n'est pas de la taille spécifiée pour l'entrée de la strucutre, la fonction échoue.

    Y'a même pas d'exemple dans la msdn ! Je suis pas Enstein, j'ai pas inventé la physique quantique ! Puis avec mon anglais... je suis pas trop aidé.

    Je ne sais pas si je me suis bien fais comprendre mais je comprends pas vraiment où aller.

    Merci
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  6. #6
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Ben, tu te fais un tableau de INPUT (sûrement, deux: Une pour presser la touche TAB, une pour la relacher), et tu mets les bonnes valeurs dedans, puis tu fais:
    Code C : Sélectionner tout - Visualiser dans une fenêtre à part
    SendInput(2, &mesInputs, sizeof(INPUT));
    Tu devrais avoir plus d'infos dans la doc de la structure INPUT...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  7. #7
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Suis-je sur la bonne voix ?
    Ca compile pas, il ne reconnait pas le INPUT donc Letter aussi.

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include <iostream>
     
    int main (void)
    {
         char Stream[]   = "MyStream"                 ;
         int  StreamSize = sizeof(Stream)/sizeof(char);
     
         INPUT *Letter     ;
         Letter = new INPUT;
     
         Letter->type       = INPUT_KEYBOARD;
         Letter->ki.wVk     = 0             ;
         Letter->ki.dwFlags = 0             ;
         Letter->ki.time    = 0             ;
         Letter->ki.wScan   = 0             ;
     
     
         HWND Handle = FindWindow("Notepad", NULL);
         SetForegroundWindow(Handle);
     
         int i=0;
         for ( i=0 ; i<=SteamSize ; i++ )
             {
                   Letter->ki.wVk = VkKeyScan(Stream[i]);
     
                   Letter->ki.dwExtraInfo = 0;
                   SendInput(1,Letter,sizeof(Letter));
                   Letter->ki.dwExtraInfo = KEYEVENTF_KEYUP;
     
                   i++;
             }
    }
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  8. #8
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Pourquoi l'alloues-tu dynamiquement?
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  9. #9
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include <wchar.h>
     
    int _tmain(void)
    {
       TCHAR Stream[] = _T("MyStream");
       size_t const StreamSize = sizeof Stream / sizeof *stream;
       INPUT Letter = {INPUT_KEYBOARD};     
       HWND Handle = FindWindow(_T("Notepad"), NULL);
     
       SetForegroundWindow(Handle);
     
       for(size_t i = 0; i <= SteamSize; i++)
       {
          Letter.ki.wVk = VkKeyScan(Stream[i]);
          Letter.ki.dwExtraInfo = 0;
          SendInput(1, &Letter, sizeof(INPUT));
          Letter.ki.dwExtraInfo = KEYEVENTF_KEYUP;
       }
     
       return 0;
    }
    Je n'ai pas de compilateur, je ne sais pas si c'est bon.
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  10. #10
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Je n'alloue rien dynamiquement, je parcours la chaine pour simuler la pression de tous les caractères.

    Merci pour ton code mais je ne le comprends pas. TCHAR, les _ devant les variables...

    Merci
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  11. #11
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Je n'alloue rien dynamiquement,
    tu te contredis!
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  12. #12
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Je n'alloue rien dynamiquement
    Code qui alloue dynamiquement : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
         INPUT *Letter     ;
         Letter = new INPUT;


    Merci pour ton code mais je ne le comprends pas. TCHAR, les _ devant les variables...
    Il n'y a pas de _ devant les variables, il y a seulement des _T() autour des chaînes de caractères. C'est juste pour dire qu'il s'agit d'une chaîne de TCHAR. Ça sert pour l'unicode.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  13. #13
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Autant pour moi, désolé pour mon ignorance, j'apprends un peu sur le tas.

    Je comprends pas pourquoi il trouve pas iostream du coup il reconnait pas INPUT et je ne peux pas compiler voir ce que fais le petit code que j'ai fais.

    Que ce soit ton code ou le miens impossible de compiler, pas moyen de définir INPUT.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  14. #14
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Je comprends pas pourquoi il trouve pas iostream
    Problème de namespace std? voir la FAQ.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  15. #15
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    http://cpp.developpez.com/faq/cpp/?p...PACE_using_std

    Il ne veut pas savoir non plus avec cette ligne de code ko0'. Je vais me rendre fou.
    y'a toujours INPUT undeclared ....

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include <wchar.h>
    #include <iostream>
     
    using namespace std;
     
     
    int main (void)
    {
         char Stream[]   = "MyStream"                 ;
         int  StreamSize = sizeof(Stream)/sizeof(char);
     
         INPUT *Letter     ;
         Letter = new INPUT;
     
         Letter->type       = INPUT_KEYBOARD;
         Letter->ki.wVk     = 0             ;
         Letter->ki.dwFlags = 0             ;
         Letter->ki.time    = 0             ;
         Letter->ki.wScan   = 0             ;
     
     
         HWND Handle = FindWindow("Notepad", NULL);
         SetForegroundWindow(Handle);
     
         int i=0;
         for ( i=0 ; i<=SteamSize ; i++ )
             {
                   Letter->ki.wVk = VkKeyScan(Stream[i]);
     
                   Letter->ki.dwExtraInfo = 0;
                   SendInput(1,Letter,sizeof(Letter));
                   Letter->ki.dwExtraInfo = KEYEVENTF_KEYUP;
     
                   i++;
             }
    }
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  16. #16
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Euh... Y'a pas de iostream ici...

    Ben, c'est vraiment bizarre, car d'après la doc, tu as les headers qu'il faut...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  17. #17
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    d'après la MSDN, INPUT est déclaré dans windows.h : http://msdn.microsoft.com/en-us/libr...70(VS.85).aspx
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  18. #18
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Je suis maudit, c'est tout xD.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

  19. #19
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Citation Envoyé par darkwall_37 Voir le message
    Je suis maudit, c'est tout xD.
    "The quieter you become, the more you are able to hear"
    "Plus vous êtes silencieux, plus vous êtes capable d'entendre"

  20. #20
    Membre confirmé
    Homme Profil pro
    amateur
    Inscrit en
    Octobre 2007
    Messages
    731
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : amateur

    Informations forums :
    Inscription : Octobre 2007
    Messages : 731
    Points : 460
    Points
    460
    Par défaut
    Je sais plus quoi faire. C'est peut être à cause de dev c++ tout pourris.
    UNE REPONSE UTILE : &|| UN PROBLEME RESOLU :

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [VB.Net] "Impossible de créer le handle de fenêtre"
    Par cedric_g dans le forum Windows Forms
    Réponses: 4
    Dernier message: 06/04/2006, 12h49
  2. Focus fenêtre + accès aux champs
    Par Pymm dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 28/07/2005, 12h07
  3. comment changer le handle de fenêtre
    Par latisane dans le forum MFC
    Réponses: 21
    Dernier message: 20/01/2005, 18h42
  4. [Window] Handle de fenêtre
    Par el_diablos dans le forum API, COM et SDKs
    Réponses: 2
    Dernier message: 01/07/2004, 14h12
  5. Lister le contenu d'une table sans connaitre ses champs
    Par Google.be dans le forum PostgreSQL
    Réponses: 9
    Dernier message: 30/03/2004, 15h23

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