-
First of all, anyone know how to get the username of the currently logged on user?
Second of all, how can i tell how long the pc has been idle, no mouse movement and no keyboard movement?
Thirdly, regarding access databases being used through vb, if i have several the same on several servers, how do i go about syncing them at the end of the days work?
Thanks :)
-
1. I've answered that user logged qwestions
http://forums.vb-world.net/showthrea...threadid=35327
2.
Put this code in a module
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Type POINTAPI
x As Long
y As Long
End Type
Function IddleTime() As Long
Static start As Long, mousepos As POINTAPI, testpos As POINTAPI
For x = 0 To 255
If (GetAsyncKeyState(x) <> 0) Then start = GetTickCount
Next x
GetCursorPos testpos
If testpos.x <> mousepos.x Or testpos.y <> testpos.y Then mousepos = testpos: start = GetTickCount
IddleTime = GetTickCount - start
End Function
And call iddletime function very frequently, for instance in a timer:
Code:
Private Sub Timer1_Timer()
Caption = IddleTime
End Sub
Set it's interval to 60