PDA

View Full Version : check the time of last time keyboard is pressed



Aki Tomar
5th February 2008, 08:56
Dear Friends;
Is there is any idea to check that when was last time keyboard is pressed.

marcel
5th February 2008, 09:09
First of all please stop posting non-Qt related questions in the Qt Programming section.
As for your question, take a look at the Win API function GetLastInputInfo. (http://msdn2.microsoft.com/en-us/library/ms646302%28VS.85%29.aspx)
There is a C# example here: http://www.codeproject.com/KB/cs/GetIdleTimeWithCS.aspx. (http://www.codeproject.com/KB/cs/GetIdleTimeWithCS.aspx)
It is very easy to see how that API should be used.

ashukla
5th February 2008, 09:10
You can store the value of current system Date/Time using with QDateTime QDateTime::currentDateTime () in the KeyPressEvent of any widget;
Define a
QDateTime latestTime(); object in your header file and then in the KeyPressEvent of your Widget.

void keyPressEvent(QKeyEvent *event)
{
latestTime=currentDateTime ();
}
it may helps!