win32api.GetLastInputInfo

int = GetLastInputInfo()

Returns time of last input event in tick count

Win32 API References

Search for GetLastInputInfo at msdn, google or google groups.