SetWindowsHookEx



  • Hi zusammen ich habe mal eine Frage dazu. Unten ist mein bisheriger Code das Funktioniert auch soweit wenn ich zum Beispiel UnhookWindowsHookEx(hook); rausnehme reagiert der Editor auf keine Taste mehr das Problem was ich habe das das Prog durchläuft und dann ist gut er springt nie in die KeyboardProc. Zu meiner Frage wie kann ich nun auf bestimmte Tastaturnachrichten reagieren und gewisse durchlassen und andere wiederrum nicht. Danke schon mal.

    #include <windows.h>

    LRESULT CALLBACK KeyboardProc(int, WPARAM, LPARAM);

    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
    {
    HWND findhwnd;
    DWORD dword;
    HHOOK hook;

    findhwnd = FindWindow(NULL, "Neu.txt - Editor");

    if(findhwnd != NULL)
    {
    MessageBox(NULL, "Gefunden", "Nachricht", MB_OK);

    dword = GetWindowThreadProcessId(findhwnd, NULL);

    hook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, NULL, dword);

    UnhookWindowsHookEx(hook);
    }
    return 1;
    }

    LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
    switch(nCode)
    {

    }

    return 1;
    }

    MfG Schirrmie

    [ Dieser Beitrag wurde am 15.06.2003 um 23:04 Uhr von schirrmie editiert. ]



  • Indem du entweder CallNextHookEx aufrufst oder nicht. Dazu steht in der MSDN-Library folgendes:

    Calling CallNextHookEx is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications.



  • Ich weiß nicht genau wie du das meinst wenn ich die Funktion aufrufe dann beendet sich der Editor gleich. Mach ich was Falsch?
    MfG Schirrmie



  • Außerdem muss das Ganze in ne DLL! Schau mal in der FAQ nach.


Anmelden zum Antworten