Its hard to answer without details of the environment/IDE/compiler you are using.
I am guessing your are using a DOS mode IDE like Turbo C/C++. If it is so your program will run in the DOS (16-bit) environment of Windows and it cannot interact with the rest of the applications running in Windows. As you said the keylogger will only work within the DOS environment (the editor and the program output screen)
If you want to develop a true keylogger for Windows in C, you'll have to learn Win32 API and write some sort of keyboard hook I guess.
vicky_dev
Junior Poster in Training
86 posts since May 2005
Reputation Points: 28
Solved Threads: 2
With some tweaking, this snippet should help.
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
What a horror !!!
It is not a keylogger at all !
Ask on Professional Win32 api Group
to learn how to make real keyloggers..
I'll agree that it's not the best keylogger, but it works. The best way is to use a windows hook, which has already been suggested.
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
There are several ways to develop key loggers on Windows. I'll list them in order worst to best:
1. You could GetAsyncKeyState() from W32 API in a loop, but I guess most of the anti-viruses would detect those easily. But it's worth to try if you are a beginner (I made my own key logger using this way).
2. Windows Hooks. I can't give you more details on those but some say this is a popular way to make key loggers.
3. Writing a malicious keyboard driver. This takes more skills to do, as well as some assembly knowledge.
The next step you'd want to take is to decide how you are going to store data your key logger makes. This depends on the purpose of the key logger. If you do this for fun, then I guess just a plain file would be good, but if you plan to use it the "not right" way or sell it you need to do some Google research. It would probably be e-mailing or sending to a remote host, maybe an FTP server?
Hope this helps
venomxxl
Junior Poster in Training
72 posts since Jan 2009
Reputation Points: 34
Solved Threads: 7
>I'll list them in order worst to best
I wouldn't say that's the best order, why create your own malicious keyboard driver when you can just use a windows hook? But transferring the information that's been logged is out of the question, as long as you get the key strokes, what happens with the data is up to s_sridhar, and doesn't really fit in any of those three points.
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
The second some AVs see something like SetWindowsHookEx imported, they'll flag it as suspicious. Of course some AVs are worth crap.
Truthfully I like the driver-in-the-middle loggers.
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116