Hello everyone,
I am creating a tool for work with Excel that will track system idle time. The idea is that a Excel can be opened on the screen, in a small box, and a cell or button will change color when system idle time reaches 55 seconds (yellow) and 60 seconds (red); system idle time being mouse clicks or keystrokes. I am having trouble conceptualizing the best way to do this.
This is my VBA code so far,
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Declare PtrSafe Sub GetLastInputInfo Lib "user32" (ByRef plii As LASTINPUTINFO)
Private Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
Function GetIdleTime() As Single
Dim a As LASTINPUTINFO
a.cbSize = LenB(a)
GetLastInputInfo a
GetIdleTime = (GetTickCount - a.dwTime) / 1000
End Function
Sub check()
Application.Wait (Now() + TimeValue("0:00:55"))
' make the system idle for 55 sec. Donot type from keyboard or click from mouse
' [Range("A1").Interior.ColorIndex = 37]
[Else[Range("A1").Interior.ColorIndex = 10]]
End Sub
it can track idle time with keystrokes and mouse clicks for 55 seconds, but I cannot figure out where to go from there.
Any help will be appreciated. Thank you.
Jen
Bookmarks