By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,971 Members | 900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,971 IT Pros & Developers. It's quick & easy.

How can I capture a keypress in a windows service?

P: n/a
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.
Mar 19 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"cashdeskmac" wrote:
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.
Mar 19 '07 #2

P: n/a
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 O''Donnell" wrote:
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
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"cashdeskmac" wrote:
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.
Mar 19 '07 #3

P: n/a
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"cashdeskmac" <ca*********@discussions.microsoft.comwrote in message
news:20**********************************@microsof t.com...
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 O''Donnell" wrote:
>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
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"cashdeskmac" wrote:
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.

Mar 19 '07 #4

P: n/a
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

Mar 19 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.