warum wird die Funktion (Keyboardproc) beim Keyboardanschlag nicht ausgeführt? Habe mir die anderen posts schon durchgelesen, und werde dadurch nicht schlau. moechte mal ein "GAAANZ" kleines programm haben, welches im hintergrund laueft und tastaturanschläge abfaengt.
vielen dank im vorraus!
mfg
#include "windows.h"
#include "stdio.h"
HHOOK g_hHookRecorder = NULL;
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam){
char msg[256];
sprintf(msg,"%d %d %d",nCode, wParam, lParam);
MessageBox(0,msg,"test",0);
return (CallNextHookEx(g_hHookRecorder, nCode, wParam, lParam));
};
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{
SetWindowsHookEx(WH_KEYBOARD, KeyboardProc,hInstance,0);
while(1==1) {
int d_ergebnis = 0;
SleepEx(10000,1);
d_ergebnis = MessageBox(0, "Programm fortsetzen?", "Hooker",MB_YESNO);
if (d_ergebnis == IDNO) break;
};
UnhookWindowsHookEx( g_hHookRecorder );
return TRUE;
}
vielen dank im vorraus!
mfg
#include "windows.h"
#include "stdio.h"
HHOOK g_hHookRecorder = NULL;
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam){
char msg[256];
sprintf(msg,"%d %d %d",nCode, wParam, lParam);
MessageBox(0,msg,"test",0);
return (CallNextHookEx(g_hHookRecorder, nCode, wParam, lParam));
};
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{
SetWindowsHookEx(WH_KEYBOARD, KeyboardProc,hInstance,0);
while(1==1) {
int d_ergebnis = 0;
SleepEx(10000,1);
d_ergebnis = MessageBox(0, "Programm fortsetzen?", "Hooker",MB_YESNO);
if (d_ergebnis == IDNO) break;
};
UnhookWindowsHookEx( g_hHookRecorder );
return TRUE;
}
Comment