New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

system idle time using visual basic applications

Macros, VBA, Excel Automation, etc.

system idle time using visual basic applications

Postby nileshjadhavshiv » Wed Oct 07, 2015 11:04 am

Hi Friends,

I am trying to capture system idle time using visual basic applications and i got code from below mention url also i have uplode my question on below link

Vba code as per below

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"


I want idle time in HH:MM:SS format and it should be like below

Idle start time Idle end Time Idle total time
12:00:00 12:45:00 00:45:00

URL : http://www.mrexcel.com/forum/excel-ques ... ost4303599
  • 0

nileshjadhavshiv
Rookie
 
Posts: 8
Joined: Jul 9, 2015
Reputation: 0
Excel Version: 2010

Re: system idle time using visual basic applications

Postby pecoflyer » Wed Oct 07, 2015 11:13 am

Please wrap code with the code tags. Thx
  • 0

A relevant topic title helps get faster and more answers
pecoflyer
Moderator
 
Posts: 1274
Joined: Jan 24, 2012
Location: Belgium
Reputation: 39
Excel Version: 2003/2007/2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: Google [Bot] and 224 guests