Win 32 Keyboard and Mouse Messages

Hi,

How can I get the key presses when my window is not active or it is Minimized?

The same is the case with the mouse, how can I get it's coordinates when my window is not active?

Thanks.
For keyboard, you can use keyboard hooks. Search for any key logger program that uses keyboard hooks and you will get an idea of how to use them.

For mouse you can capture the mouse using SetCpature Win32 API or CWnd::SetCapture in MFC
This gets the keyboard and mouse key state:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293.aspx

This gets the mouse location:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648390.aspx

It's been a while since I've used this, but I believe that you don't even have to have a window open to use those functions. However, I would advise not to use those functions, because some antiviruses pick them up as keyloggers. (My antivirus must be pretty stupid. It didn't catch anything.)

I would use the MSG loop to handle keyboard and mouse inputs; however, I don't believe that those work without focus on your window.
Registered users can post here. Sign in or register to post.