Home > Windows API > GetLastInputInfo


To know the tickcount 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 );
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: