Re: Check for NO ACTIVITY
I guess I'd use a timer, and get the mouse coordinates once every minute. If they are the same, then increment a variable. If different, reset the variable to zero. At the end of the timer event, you could then check the value of the variable, and if it is high enough, call your logout code.
Re: Check for NO ACTIVITY
I also had to do this recently, but my program design lent itself useful for this check (and yours might not).
I had a "kerrnel" for my application, where all data and interface calls got filtered through. When you requested to go to a certian view pane, the core said if you had permission... when you tried to add/delete/view data, the kernel said if you had permission.
That also made it really easy for me to reset the timer. Anytime a call into that subsystem, the timer was reset... after X minutes, I'd force a logout using a WM_TIMER.
Besides keeping track of user activity yourself, I'm not sure what you can do. You can monitor their idle time, but I'm not sure what level of security you need here; for me, idle time wasn't enough... I needed to know if actual activity was going on, not just mouse movements and such.
Re: Check for NO ACTIVITY
I quickly slammed this thingy together.
Hopefully it helps!
Re: Check for NO ACTIVITY
Quote:
Originally Posted by WizBang
I guess I'd use a timer, and get the mouse coordinates once every minute. If they are the same, then increment a variable. If different, reset the variable to zero. At the end of the timer event, you could then check the value of the variable, and if it is high enough, call your logout code.
Good call. Yes, this is good enough for my application. It works really good.
Thanks guys.
Re: Check for NO ACTIVITY
i would use 2 system wide hooks. one watching the keyboard the other watching the mouse. then evertime a command is received, restart a timer. if the timer reaches 0 then you know the user is inactive.
problem with only checkking the mouse cursor is when users are typing a document. i often don't use the mouse for minutes on end when typing up docs.
Re: Check for NO ACTIVITY
Quote:
Originally Posted by Pinky98
i would use 2 system wide hooks. one watching the keyboard the other watching the mouse. then evertime a command is received, restart a timer. if the timer reaches 0 then you know the user is inactive.
problem with only checkking the mouse cursor is when users are typing a document. i often don't use the mouse for minutes on end when typing up docs.
This is good except that some optical mice will occassionally register movement falsely, if the surface they are resting on isn't smooth or painted somewhat colorfully. So, there could be inactivity but the "movement" of the mouse prevents a logoff from occurring. You may want to consider igoring mouse movement in your hooks and only have key presses and mouse clicks represent actual activity.
Re: Check for NO ACTIVITY
Quote:
Originally Posted by NatThoelecke
This is good except that some optical mice will occassionally register movement falsely, if the surface they are resting on isn't smooth or painted somewhat colorfully. So, there could be inactivity but the "movement" of the mouse prevents a logoff from occurring. You may want to consider igoring mouse movement in your hooks and only have key presses and mouse clicks represent actual activity.
Did you know that the minimum amount of movement required to register as a mouse event is called a "mickey"? :D
You could have a minimum value like 15 pixels and if the mouse moves that distance then it resets the timer, otherwise it is ignored. Users' don't often move the mouse very small distances.
Re: Check for NO ACTIVITY
Good calls. Very interesting.
However; with my application, the user must use the mouse to do works (they don't have to type documents :)...) and they don't use wireless mouse because it easy to walk away by itself.
Thank you for your inputs.