pawanhsharma
Board Regular
- Joined
- Feb 12, 2013
- Messages
- 64
Hello all,
I am currently working on a project where I need to count system Idle time through the working hours,
i have checked most of the codes available online but no success
I am having a simple code which i am currently using where user need to start the timer once he start working and stop/pause it when he moved for a break or so, but as it can be managed I am not getting the output as desired.
the code is as below..
Dim StopTimer As Boolean
Dim Etime As Single
Dim Etime0 As Single
Dim LastEtime As Single
Dim tcount As Single
Private Sub ExitBtn_Change()
If ExitBtn.Value = True Then
StopTimer = True
Sheets("sheet1").Range("b2").Value = ElapsedTime.Text
tcount = 0
Unload Me
End If
End Sub
Private Sub ResetBtn_Change()
If ResetBtn.Value = True Then
StopTimer = True
Etime = 0
Etime0 = 0
LastEtime = 0
tcount = 0
ElapsedTime.Text = "00:00:00"
End If
End Sub
Private Sub StartBtn_Change()
If StartBtn.Value = True Then
StopBtn.Value = False
StopTimer = False
Sheets("sheet1").Range("b2").Value = tcount
Etime = tcount
Etime0 = Timer() - LastEtime
Etime0 = Sheets("sheet1").Range("b2").Value
Do Until StopTimer
Etime = Int((Timer() - Etime0) * 100) / 100
If Etime > LastEtime Then
LastEtime = Etime
ElapsedTime.Text = Format(Etime / 86400, "hh:mm:ss") '& Format(Etime * 100 Mod 100, "00")
DoEvents
End If
Loop
End If
End Sub
Private Sub StopBtn_Change()
If StopBtn.Value = True Then
StartBtn.Value = False
Sheets("sheet1").Range("b2").Value = ElapsedTime.Text
tcount = Sheets("sheet1").Range("b2").Value
StopTimer = True
'Beep
'TextBox1.Value = ElapsedTime.Text
End If
End Sub
I just want the time to be start when system is idle for 5 minur=tes and pause when user get active thats it.. system idle time code is available on web but not sure which goes right and how to link it with my code.
I am currently working on a project where I need to count system Idle time through the working hours,
i have checked most of the codes available online but no success
I am having a simple code which i am currently using where user need to start the timer once he start working and stop/pause it when he moved for a break or so, but as it can be managed I am not getting the output as desired.
the code is as below..
Dim StopTimer As Boolean
Dim Etime As Single
Dim Etime0 As Single
Dim LastEtime As Single
Dim tcount As Single
Private Sub ExitBtn_Change()
If ExitBtn.Value = True Then
StopTimer = True
Sheets("sheet1").Range("b2").Value = ElapsedTime.Text
tcount = 0
Unload Me
End If
End Sub
Private Sub ResetBtn_Change()
If ResetBtn.Value = True Then
StopTimer = True
Etime = 0
Etime0 = 0
LastEtime = 0
tcount = 0
ElapsedTime.Text = "00:00:00"
End If
End Sub
Private Sub StartBtn_Change()
If StartBtn.Value = True Then
StopBtn.Value = False
StopTimer = False
Sheets("sheet1").Range("b2").Value = tcount
Etime = tcount
Etime0 = Timer() - LastEtime
Etime0 = Sheets("sheet1").Range("b2").Value
Do Until StopTimer
Etime = Int((Timer() - Etime0) * 100) / 100
If Etime > LastEtime Then
LastEtime = Etime
ElapsedTime.Text = Format(Etime / 86400, "hh:mm:ss") '& Format(Etime * 100 Mod 100, "00")
DoEvents
End If
Loop
End If
End Sub
Private Sub StopBtn_Change()
If StopBtn.Value = True Then
StartBtn.Value = False
Sheets("sheet1").Range("b2").Value = ElapsedTime.Text
tcount = Sheets("sheet1").Range("b2").Value
StopTimer = True
'Beep
'TextBox1.Value = ElapsedTime.Text
End If
End Sub
I just want the time to be start when system is idle for 5 minur=tes and pause when user get active thats it.. system idle time code is available on web but not sure which goes right and how to link it with my code.