Bonjour j'aimerais récupérer les messages envoyer aux application.
Pour le moment, j'ai ce morceau de code mais des que je compiles, il fait bug mon PC. Pouvez vous m'aider ?
merci

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
#include <windows.h>
#include <iostream>

HHOOK hook ;
HANDLE hThread;

LRESULT CALLBACK hooker(int nCode, WPARAM wParam, LPARAM lParam)
{
    if  ((nCode == HC_ACTION) && (wParam == WM_KEYDOWN)) {
        MSG   hooked =  *((PMSG)lParam);
    }
    return CallNextHookEx(hook,nCode,wParam,lParam);
}

void Loop() {

 MSG message;
 while (GetMessage(&message,NULL,0,0)) {
    TranslateMessage( &message );
    DispatchMessage( &message );
 }

}

WORD WINAPI thread(LPVOID lpParameter) {

    HINSTANCE hExe = GetModuleHandle(NULL);
    hook = SetWindowsHookEx(WH_GETMESSAGE,hooker,hExe,0);

    Loop();
    return 0 ;
}

int main()
{

    hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE) thread,
                    (LPVOID)NULL,NULL,NULL);

    if( hThread )
        return WaitForSingleObject(hThread,INFINITE);
    else
        return 0;

}