Bonjour,

J'ai un soucis avec QT et les handles, la fonction FindWindows ne marche pas, il y a un problème de convertion.

Il me dit exactement : cannot convert "const char*" to "const WCHAR*" pour l'argument de la fonction FindWindows.

En même temps je n'ai qu'à pas utiliser des fonctions de l'api32 dans QT mais je ne sais pas faire autrement pour faire de la simulation de touches ciblées & je ne connais pas d'équivalent pour postmessage et FindWindows dans QT.

Y'a t-il un moyen de palier ce problème ?

Merci d'avance

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
// 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 *PrintTimer, QString QID, QString QPW, QString QRepeat, QString QTimer, int X, int Y);
void Write(char *Flux, int Size);
void ENTER( HWND TargetedHandle);
void WAIT();
void TAB();
 
 
 
// 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");
    GetPrivateProfileStringA("Settings",  "TIMER", "", Timer , 999, ".//autorun.ini");
 
    /* Convertion en QString des ID & PW */
    QString QID     = QString(ID);
    QString QPW     = QString(PW);
    QString QRepeat = QString(Repeat);
    QString QTimer  = QString(Timer);
 
	/* Création des objets */
	PrintTitle      = new QLabel     (         this);
    PrintID         = new QLabel     (         this);
    PrintPW         = new QLabel     (         this);
    PrintRepeat     = new QLabel     (         this);
    PrintTimer      = new QLabel     (         this);
    PrintAuthor     = new QLabel     (         this);
    PrintVersion    = new QLabel     (         this);
    Start           = new QPushButton("Start"   , this);
    Stop            = new QPushButton("Quitter" , this);
    Download        = new QPushButton("Download", this);
    Picture         = new QPixmap    ("image.jpg"  );
    Frame           = new QLabel     (this         );
 
        /* Initialisation de l'affichage */
    InitDisplay( Start, Stop, Download, PrintAuthor, PrintVersion, PrintTitle, PrintID, PrintPW, PrintRepeat, PrintTimer, QID, QPW, QRepeat, QTimer, 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 *PrintTimer, QString QID, QString QPW, QString QRepeat, QString QTimer, int X, int Y)
{
 
    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     );
    PrintTimer   -> setText("<strong><small>TIMER</small></strong> : " + QTimer +" ms");
    PrintAuthor  -> setText("<small>® DARKWALL_37</small>");
    PrintVersion -> setText("<small>V1.04</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 );
    PrintTimer   -> move( (X - PrintTimer    -> minimumSizeHint().width())/2, 0.60*Y );
    PrintAuthor  -> move( 0.01*X, 0.01*Y );
    PrintVersion -> move( X - (PrintVersion -> minimumSizeHint().width() + 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");
 
    /* Taille de ID & PW */
    int IDSize=strlen(ID);
    int PWSize=strlen(PW);
 
    WAIT();
 
    HWND Handle = FindWindow("Notepad",NULL);
 
    Write(ID, IDSize);
    TAB();
    Write(PW, PWSize);
 
    int LoopNumbers = atoi(Repeat);
    int control     = 0           ;
 
    if (Handle)
       { 
               while ( control != LoopNumbers )
                     {
 
                           ENTER(Handle);
                           control++;      
                     }
       }    
}
 
 
void Write(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    {
                                              keybd_event(VkKeyScan(Flux[i]),0,0,0);
                                              _sleep(40);
                                           }
                                 }
 
}
 
 
void WAIT()
{
     _sleep(5000);
}
 
 
void TAB()
{
     keybd_event(VK_TAB,0,0,0); 
     _sleep(500);
     keybd_event(VK_TAB,0,KEYEVENTF_KEYUP,0);                           
     _sleep(500);       
}
 
void ENTER(HWND TargetedHandle)
{
    SendMessage(TargetedHandle,WM_CHAR,VK_RETURN,0);
    _sleep(500);                            
}