Hi,
I have been working on a form to be supplied to my production floor to capture production but also wanted to have a feature where I know how much time a guy spends away from system (Non Productive).
I found a code which gets me very close to what I want but with a headache . I am unable to figure out how to get the data on a specific sheet instead of immediate window so I can sum it up..
Need you to help me get this output on a sheet instead..
Paste the below code in a module, Open the immediate window and run printidletime1. Every 5 seconds you would see immediate window popping up the idle time.
I have been working on a form to be supplied to my production floor to capture production but also wanted to have a feature where I know how much time a guy spends away from system (Non Productive).
I found a code which gets me very close to what I want but with a headache . I am unable to figure out how to get the data on a specific sheet instead of immediate window so I can sum it up..
Need you to help me get this output on a sheet instead..
Paste the below code in a module, Open the immediate window and run printidletime1. Every 5 seconds you would see immediate window popping up the idle time.
Code:
<DIR>Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Declare Sub GetLastInputInfo Lib "user32" (ByRef plii As LASTINPUTINFO)
Private Declare Function GetTickCount Lib "kernel32" () As Long
Function IdleTime() As Single
Dim a As LASTINPUTINFO
a.cbSize = LenB(a)
GetLastInputInfo a
IdleTime = (GetTickCount - a.dwTime) / 1000
End Function
Sub PrintIdleTime1()
Debug.Print IdleTime
Application.OnTime Now + TimeSerial(0, 0, 5), "PrintIdleTime2"
End Sub
Sub PrintIdleTime2()
Debug.Print IdleTime
Application.OnTime Now + TimeSerial(0, 0, 5), "PrintIdleTime1"
End Sub
</DIR>