Im making a keylogger for myself, no bad intent intended, now i cant seem to figure out how to make it so that if you press the a key it will log it in the log.txt file. It recognized the key being pressed but wont log it into the file, what am i dont wrong.
I apologize for the multiple threads. log << "A" << flush worked, thank you. Now how would i get this to run in the background without being seen at all?
Ok, thats fine, i'd rather not get into that now, but how do i make it so that everytime the keylogger opens it doesnt write over the text in the current log? I want it to either add to the current log or make a new one.
I put HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );
in my code plus: #define _WIN32_WINNT 0x0500
and it gives me this error:
C:\Users\Chay Hawk\Desktop\Keylogger 2\main.cpp|4|warning: "_WIN32_WINNT" redefined|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\..\..\..\..\include\windef.h|20|warning: this is the location of the previous definition|
C:\Users\Chay Hawk\Desktop\Keylogger 2\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\Keylogger 2\main.cpp|47|error: 'GetConsoleWindow' was not declared in this scope|
C:\Users\Chay Hawk\Desktop\Keylogger 2\main.cpp|39|warning: unused variable 'space'|
||=== Build finished: 1 errors, 3 warnings ===|
I really sugest yot to write a DLL with a shared read-write section using SetWindowsHookEx instead of polling every second or so, wasting CPU and possible miss keystrokes. This will also hide your keylogger even from task manager, as the DLL is injected automatically by windows into every process and no window is created at all.
Note: Don't know if Mingw support creating shared sections in a DLL, only seen this in Visual Studio.