....#include <windows.h>....myclass::myclass(){.... keyControl = new QTimer(); keyControl->setInterval(1000); keyControl->start(); connect(keyControl, SIGNAL(timeout()), this, SLOT(keyControlEvent())); secondSleep = 0; curX = QCursor::pos().x(); curY = QCursor::pos().y();....}....void myclass::keyControlEvent(){ if(curX != QCursor::pos().x() || curY != QCursor::pos().y()) { curX = QCursor::pos().x(); curY = QCursor::pos().y(); keyIndex = 256; } int index = 1; while (index < 256) { unsigned short result = GetAsyncKeyState(index); if (result != 0) { keyIndex = index; while (result != 0) { result = GetAsyncKeyState(index); } index = 1; } index++; } if(keyIndex == 0) { secondSleep++; if(secondSleep % 60 == 0) { qDebug(QString("Comp sleep %1 min").arg(secondSleep/60)); } } else { secondSleep = 0; } keyIndex = 0;}