May 242007
 

To know the tick count of last input event use GetLastInputInfo api.

Here is a demo…

// Prepare last input information structure
LASTINPUTINFO lipInfo = { 0 };
lipInfo.cbSize = sizeof( LASTINPUTINFO );

// Sleep for one second
Sleep( 1000 );

// Get last input tick count
GetLastInputInfo( &lipInfo );

// Milliseconds elapsed since last event
const DWORD dwElapsedTickCount = GetTickCount() - lipInfo.dwTime;

// Show time elapsed since last tickcount
CString csMsg;
csMsg.Format( _T( "Time since last input: %lu ms" ), dwTimeSince );
MessageBox( csMsg );

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.