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