How to detect 'Idle' status in Mac (Qt\C++ application)
Publicado por Diego (3 intervenciones) el 26/07/2019 12:47:54
Hi,
I have a C++/Qt application for Win & Mac where I need to know if the user is in an 'idle' status (no user interaction in X minutes).
In Windows I am using GetLastInputInfo and it is working perfectly:
....
// Get the last input event info.
LASTINPUTINFO li;
li.cbSize = sizeof(LASTINPUTINFO);
::GetLastInputInfo(&li);
// Calculate the time elapsed in seconds.
DWORD te = ::GetTickCount();
int elapsed = (te - li.dwTime) / 1000;
....
For Mac I have read that CGEventSourceCounterForEventType could help me. But I can not find how to use it in a C++ method
I would thank any help,
Diego
I have a C++/Qt application for Win & Mac where I need to know if the user is in an 'idle' status (no user interaction in X minutes).
In Windows I am using GetLastInputInfo and it is working perfectly:
....
// Get the last input event info.
LASTINPUTINFO li;
li.cbSize = sizeof(LASTINPUTINFO);
::GetLastInputInfo(&li);
// Calculate the time elapsed in seconds.
DWORD te = ::GetTickCount();
int elapsed = (te - li.dwTime) / 1000;
....
For Mac I have read that CGEventSourceCounterForEventType could help me. But I can not find how to use it in a C++ method
I would thank any help,
Diego
Valora esta pregunta


0