in reply to windows events

If you're trying to determine if the keyboard is idle. You could interface to the GetLastInputInfo function using Win32:API. This returns a LASTINPUTINFO structure that contains the tick count since the last input event. The difference between this value and the actual tick count since system boot will give the milliseconds since last input. For example: -
use strict; use Win32::API; my $tc = Win32::GetTickCount(); Win32::API::Struct->typedef( LASTINPUTINFO => qw{ UINT cbSize; DWORD dwTime; } ); Win32::API->Import("user32", 'BOOL GetLastInputInfo(LPLASTINPUTINFO pl +ii)'); my $li = Win32::API::Struct->new('LASTINPUTINFO'); $li->{cbSize} = $li->sizeof; # MSDN: Must be set to sizeof(LASTINPUTIN +FO) GetLastInputInfo($li); print $li->{dwTime} - $tc, "\n";