I use this and it works great


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 ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim CurPos As POINTAPI
Dim OldX As Single
Dim OldY As Single
Dim StartTime As Date

Function Start()
StartTime = Format(Time, "hh:mm:ss")
End Function

Private Sub Form_Load()

Start
Timer1.Interval = 1

End Sub


Private Sub Timer1_Timer()

For I = 32 To 127
If GetAsyncKeyState(I) Then Start
If GetAsyncKeyState(vbLeftButton) Then Start
If GetAsyncKeyState(vbRightButton) Then Start

Next

MyPos = GetCursorPos(CurPos)


X = CurPos.X
Y = CurPos.Y
If OldX = X And OldY = Y Then
'The mouse is still
Else
'the Mouse is not still
OldX = X
OldY = Y

Start

End If


retval = StartTime - Time
retval = Format(retval, "hh:mm:ss")
If retval = "00:00:10" Then
MsgBox "I work"
End If



End Sub