Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Hooks

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Ben Stephens (Visitor) Jul 20, 2001
I have been trying for ages to create a keyboard hook, but my program doesn't work, and I have absolutely no idea why. I have tried for hours to get this to work, I've e-mailed one of the guys at microsoft, and also looked at several example downloads and I am still stuck. I am new to using DLLs and hooks, and I would REALLY apprieciate some input on this! Thanks

The program I've been trying to do can be found at

It is supposed to put a message on the screen every two seconds. If you press escape, it should display "Timer Dead" and then stop the messages, but this only works when the program window is selected.

I'm using Windows 98 if that matters.
 
which OS do you use? John Fill
1c.bmp


ivfmd@mail.md
 
How about this one?
#include<windows.h>
HHOOK x=0;
LRESULT CALLBACK KeyboardProc(int code,WPARAM wParam,LPARAM lParam)
{
//put here code to hook
return 1;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int)
{
x=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,hInstance,0);
MSG msg;
while(GetMessage(&msg,0,0,0))DispatchMessage(&msg);
return 0;
}
John Fill
1c.bmp


ivfmd@mail.md
 
I've got a working system hook procedure, but I can't get it to send messages to my WndProc? How do I do this, for a custom message?
 
where is //put your code here pur your SendMessages. The program will terminate(i.e. exit the main message loop) when is called PostQuitMessage(SomeIntValue) John Fill
1c.bmp


ivfmd@mail.md
 
OK, I've tried SendMessage, PostMessage, PostThreadMessage getting the thread ID as a global variable in WinMain. Still, I just can't call the WndProc from the hook function. Why is this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top