Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetLastInputInfo() always 0 (zero)

I want to detect the idle time (eg. How long ago the user pressed a key or moved the mouse). Supposedly the GetLastInputInfo() should be what I need but, when I use it, it always prints 0.

LASTINPUTINFO   last_input  =   {0};
GetLastInputInfo(&last_input);
cout << last_input.dwTime << endl;

Any idea why?

Thank you

EDIT: Using getlasterror, it says that the parameter is incorrect (ERROR_INVALID_PARAMETER, 87)

like image 804
Cornwell Avatar asked Sep 05 '25 03:09

Cornwell


1 Answers

Solved! Forgot about initializing cbSize ...

like image 91
Cornwell Avatar answered Sep 07 '25 19:09

Cornwell