Results 1 to 10 of 10

Thread: check if workstation is being used

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    check if workstation is being used

    Hello is there a way or API to check if the workstation is in use? meaning if the user moves the mouse, type on the keyboard, etc. to know for sure that the user is still using the workstation?

  2. #2
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: check if workstation is being used

    yes, there is API to read the mouse pointer position, so you can compare if it moves

    IIRC GetCursorPos

    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

  3. #3
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: check if workstation is being used

    offcourse it must remember when was the last time the mouse moves, set a timeout time, while timeout is not zero it can return that there is activity. after the timeout gets zero, it can say that the user is AFK.

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: check if workstation is being used

    Maybe something like:

    Code:
    Option Explicit
    
    Private Const IDLE_INTERVAL As Long = 5000 'Milliseconds.
    
    Private Type tagLASTINPUTINFO
        cbSize As Long
        dwTime As Long
    End Type
    
    Private Declare Function GetLastInputInfo Lib "user32" ( _
        ByRef plii As tagLASTINPUTINFO) As Long
    
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    
    Private LII As tagLASTINPUTINFO
    Private IsIdle As Boolean
    
    Private Sub Form_Load()
        AutoRedraw = True
    
        LII.cbSize = Len(LII)
        Print "User is active"
        Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
        Dim TimeNow As Long
    
        TimeNow = GetTickCount()
        GetLastInputInfo LII
        If IsIdle Then
            If TimeNow <= LII.dwTime Then
                IsIdle = False
                Cls
                Print "User is active"
            End If
        Else
            If TimeNow - LII.dwTime > IDLE_INTERVAL Then
                IsIdle = True
                Cls
                Print "User has been idle for " _
                    & CStr(IDLE_INTERVAL \ 1000) _
                    & " seconds"
            End If
        End If
    End Sub
    Attached Files Attached Files

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: check if workstation is being used

    What if the user is watching a movie ?

  6. #6
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: check if workstation is being used

    Quote Originally Posted by DataMiser View Post
    What if the user is watching a movie ?
    normaly you are wanting to know if the user is AFK or not, is because you are doing a chat system, where you want to know if the user are online, or just the system is connected, so , you can do *DOUBLE CHECKS* , and if you want to invent the *TRIPLE CHECK* or to report the user as AFK vs OTK.

    In the same way if the user is watching a movie, he is not going to see / respond the chat box.
    Last edited by flyguille; Mar 28th, 2013 at 05:26 PM.

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: check if workstation is being used

    I did not see anything about chat in the original question, poster asked how to tell if the Workstation was in use. Watching a movie, burning a DVD, downloading 20gigs all count as in use from my point of view and in all of these cases the user may not be moving the mouse or typing anything yet still using the workstation.

  8. #8
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: check if workstation is being used

    again, tecnically you want to know IF the user is using the computer or not, if it is downloading 20GB for sure the user left the computer alone.

    the same for burning a DVD , who de hell waits watching the progressbar nowadays?

    is for sure if there is no movements on the mouse, by sure that the user is not present, by a very little margin of error.

    mouse pointer is moved like every 30 seconds or less.

  9. #9
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: check if workstation is being used

    Just had an idea, dob't know if it could be good or bad but what if every 15minute (less or more) it would pop a maximized form all one color like a screensaver and user has to move the mouse to make it go away that way if hea watching a movie or download 20gig be will still have to move the mouse once in a while if he wants to see that movie or if he wants to see his download progressbar
    This way your sure that the user is there. I would agree with DataMiser about watching a movie would still be using a workstation, but what if user left? How will you ever know until he comes back? Simple make a fake screensaver! As soon as you move mouse it disappears.

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: check if workstation is being used

    It really depends on what the OPs goal is here and what they define as not in use. Since the OP has not responded we can only guess.

    IMO there is a big difference between being away from the computer and the computer being not in use. I do lots of things on my PC that have me not using the mouse or keyboard for periods of time yet I am using the computer during that time, running calculations, compressing files, archiving, burning dvds, watching a movie or whatever, the list is long. If it is for a chat program then keystrokes would likely be good enough and a user could be considered away if no activity for x minutes but then again chat programs are of very little use today, I would never think of writing one now, 10-15 years ago maybe but with so many free ones out there plus unlimited phone time there is not much point in it.

    But again if the goal is to see if the workstation is in use the only way I really know of would be to check and see if a user is logged in and if so consider it in use, of course this would require the program run as a service so it could run when no user is logged on.

    Having a fake screen saver pop up would be extremely annoying. I would surely delete the program and complain to the author if I were the end user.

Posting Permissions

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



Click Here to Expand Forum to Full Width