system idle time using timer

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 :mad:

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.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top