Windows keyhook freezing

189 Views Asked by At

When ever i run this program my computer seems to freeze up and is unable to do anything. I think this is because i am for some reason always calling the keyboard helper function? could it be something to do with the pause that i have at the bottom of the program or is it something more. all that is contained inside the pause header and function is a getchar()

#include "pause.h"
#include <iostream>
#define null NULL
#include <Windows.h>
#pragma comment(lib,"user32.lib")


using namespace std;
HHOOK hHook=null;
char word[]="hello"; 

LRESULT CALLBACK KeyboardHelper(int nCode, WPARAM wParam,LPARAM lParam)
{
    return CallNextHookEx(hHook,nCode,wParam,lParam);
}

int main(void)
{

    hHook=SetWindowsHookEx(WH_KEYBOARD_LL,KeyboardHelper,null,0);
    if(hHook==null)
    {
        cout<< "Hook failed"<<endl;
    }else 
    {
        cout<< "Worked"<<endl;
    }
    pause();
}
0

There are 0 best solutions below