How can I capture a keypress in a windows service?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know how to capture a keypress for a windows application, but how would I
go about doing it for a windows service?

Rather than having a form in focus all the time, I would prefer to have
something running in the background. There are option such as having the
form invisible (opacity set to zero) and settings it's location as -200, -200
so that it isn't on the screen, but this isn't the ideal solution.
 
What is the effect you are trying to achieve. You cannot show a form from a
service but you might not want a service, you might be interested in a
notfify icon
 
Basically I am trying to create a crude keylogger application. I didn't want
to show a form from the Windows service (using a Windows form was an
alternative option, and although it works, it is not the ideal way to capture
all key strokes).

I would rather have the windows service running in the background from the
moment the computer starts to the moment is closes down.

I realise that there are free keyloggers available on the web but I would
like to add my own functionality.
 
Ciaran,

A service in this case is not the correct solution. A service is not
aware of the currently logged on session, as there could be no current
session, or multiple sessions.

What you want to do is have a program run when the user logs on, and
then have that insert a windows hook which will capture the keystrokes.

Hope this helps.
 
Goodluck with writing your keylogger. The windows api for this is
hellish (also it only runs in unmanaged code)... personally I think
you should buy a commercial application. However, follow that link it
has some great examples of viewing keypress events in C# ( and
suppressing them ). Also capturing CTRL+ALT+DEL and passwords is a
whole different ballgame but that link does support it.

http://www.dwinlock.kassl.de/

-James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top