dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Check for NO ACTIVITY

  1. #1
    Join Date
    Jul 2005
    Location
    Mid-West, USA
    Posts
    47

    Check for NO ACTIVITY

    Hi everyone,

    My program has a LOG IN screen. In order to use the program you need to log in. I want to have a function/sub/timer... or anything that will check to see if there is NO ACTIVITY for a certain time (15, 20, or 30 minutes). If this is true (No Activity = true), the program will automatically log you out and reverse back to the LOG IN screen.

    What is the best way to do it and how to do it.

    Please help.
    THanks,

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    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.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658

    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.
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,267

    Re: Check for NO ACTIVITY

    I quickly slammed this thingy together.

    Hopefully it helps!
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

  5. #5
    Join Date
    Jul 2005
    Location
    Mid-West, USA
    Posts
    47

    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.

  6. #6
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569

    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.
    Mike

  7. #7
    Join Date
    Jan 2004
    Location
    San Diego
    Posts
    148

    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.
    Death is life's special way of telling you you're fired.

    For I do not seek to understand in order to believe, but I believe in order to understand. For I believe this: unless I believe, I will not understand. - Anselm of Canterbury (10331109)

  8. #8
    Join Date
    May 2005
    Location
    Sunny Adelaide
    Posts
    66

    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"?

    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.
    You are here.

  9. #9
    Join Date
    Jul 2005
    Location
    Mid-West, USA
    Posts
    47

    Talking 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)