C/C++ IsUserAFK
Hey
With this function you can check, if a user is afk. It´s only a simple project, you can change many thinks to make it better, f.E: the Sleep function. But i hope people will learn from it.
With this function you can check, if a user is afk. It´s only a simple project, you can change many thinks to make it better, f.E: the Sleep function. But i hope people will learn from it.Code:
// coded by Inmate
#include <windows.h>
#include <iostream>
using namespace std;
bool CheckAFK(int delay, bool isAFK = false);
int main()
{
if (CheckAFK(1000)){
//Mache irgendwas...
}
getchar();
}
bool CheckAFK(int delay, bool isAFK)
{
if ( delay < 1000 ){
MessageBoxA(NULL, "Bitte größere Delay Anzahl angeben." ,"Error", NULL);
return 0;
}
int xPoint, yPoint, xPointNew, yPointNew;
POINT position;
GetCursorPos(&position);
xPoint = position.x;
yPoint = position.y;
if ( xPoint == 0 || yPoint == 0 ){
MessageBoxA(NULL, "Die Mauszeiger Position konnte nicht richtig gelesen werden." ,"Error", NULL);
return 0;
}
//cout << "Y Alt: " << yPoint << "\n" << "X Alt: " << xPoint << "\n";
Sleep(delay);
GetCursorPos(&position);
xPointNew = position.x;
yPointNew = position.y;
//cout << "Y Neu: " << yPointNew << "\n" << "X Neu: " << xPointNew << "\n";
if ( xPointNew == 0 || yPointNew == 0 ){
MessageBoxA(NULL, "Die Mauszeiger Position konnte nicht richtig gelesen werden." ,"Error", NULL);
return 0;
}
if ( xPoint == xPointNew && yPoint == yPointNew){
//cout << "User is afk\n";
isAFK == true;
}else{
//cout << "User is not afk";
isAFK == false;
}
}

