tracing mouse movements

Hello,

I am writing a client application that should monitor mouse movements on the computer and, in case a mouse is not moved for 5 mins, report to the server that the client is probably away (like ICQ does, but it just changes its icon to Away mode).

I think it might be done by setting a global hook for mouse movements but global hooks are strongly recommended to be avoided. I know it's not a good practice to set up a global, system hook (at least MSDN says so).

Is there another way to do that?

Thanks a lot
[557 byte] By [Captain Nemo] at [2007-11-18 22:15:01]
# 1 Re: tracing mouse movements
I am writing a client application that should monitor mouse movements on the computer and, in case a mouse is not moved for 5 mins, report to the server that the client is probably away (like ICQ does, but it just changes its icon to Away mode). A hook would be overkill in your case - to simply monitor mouse activity, you can periodically call GetCursorPos() and see if the value changes (checking every few seconds or so is certainly sufficient).
gstercken at 2007-11-11 1:04:30 >
# 2 Re: tracing mouse movements
Hm:) that's an idea:)

thanks. I think that would work
Captain Nemo at 2007-11-11 1:05:27 >
# 3 Re: tracing mouse movements
A hook would be overkill in your case - to simply monitor mouse activity, you can periodically call GetCursorPos() and see if the value changes (checking every few seconds or so is certainly sufficient).
Hi gstercken!
Thats a good solution but if someone wants to monitor keyboard activity too?? Is there anything like getting last key??
Regards,
Usman.
usman999_1 at 2007-11-11 1:06:31 >
# 4 Re: tracing mouse movements
Hi gstercken!
Thats a good solution but if someone wants to monitor keyboard activity too?? Is there anything like getting last key??No. In this case, you would have to resort to system-wide hooks.
gstercken at 2007-11-11 1:07:34 >