How to find out if any button on the keyboard was pressed to determine the user's activity (that it is not afk)?
It is ideal to take a fingerprint of the keyboard through GetKeyboardState and compare with the previous fingerprint, but it is limited to the application. Is there an analogue or asynchronous version of the function for global validation of a key?
The function for one GetKeyState button has a global version of GetAsyncKeyState . In GetKeyboardState in the standard form there is no such alternative. Perhaps there is some kind of samopnaya function?
Using a DLL trap for such a trifle seems wasteful and you don’t want to understand a whole DLL because of this + a possible fight against antivirus in this case.
GetAsyncKeyStatefunction for each key (only 256 times). Only this function is not a panacea, because if another application calls it in the interval between your calls, you will not get reliable information about the keystroke. - zedGetAsyncKeyState* 256 was a thought. But the question is: is the execution ofGetAsyncKeyState* 256 identical in speed withGetKeyboardState? - DroltromedQueryPerfomanceCounter. Checked through it. Execution duration in seconds: GetAsyncKeyState * 256 =0,0000661240with GetKeyboardState =0,0000021136It turns out that there is still a difference, even if it is not even a fraction of a second. Used the code://каждая отдельно for i:=0 to 255 do a[i]:=GetAsyncKeyState(i); //общий слепок GetKeyboardState(State);//каждая отдельно for i:=0 to 255 do a[i]:=GetAsyncKeyState(i); //общий слепок GetKeyboardState(State);- Droltromed