-
March 5th, 2012, 12:20 PM
#1
Keeping hook thread alive?
In a C++ program I'm writing I need a mouse hook active to selectively filter event messages at certain points. Putting the hook in the main thread results in significant mouse lag so I created a background thread and put the hook there.
The problem is, if I keep the background thread open with a while(1){} loop I still get the lag. Using Sleep() in the loop also causes lag, though in a slightly different way.
One thing I have found that works perfectly is opening a MessageBox() in the hook thread (no loop involved). It keeps the thread from returning and lets the mouse remain completely responsive. Now I just have a superfluous message box on my screen, and closing it ends the mouse hook.
What are my other options here? I'm fairly new to the Windows API and don't have a thorough knowledge of C++ built-in functions. I've search quite a bit but haven't found a solution, though I have a feeling the answer will be embarrassingly obvious.
-
March 6th, 2012, 01:00 AM
#2
Re: Keeping hook thread alive?
You need to run message loop in this worker thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|