364,033 Members | 4865 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

How can I capture a keypress in a windows service?

=?Utf-8?B?Y2FzaGRlc2ttYWM=?=
P: n/a
=?Utf-8?B?Y2FzaGRlc2ttYWM=?=
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


=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
P: n/a
=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
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

=?Utf-8?B?Y2FzaGRlc2ttYWM=?=
P: n/a
=?Utf-8?B?Y2FzaGRlc2ttYWM=?=
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

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

"cashdeskmac" <cashdeskmac@discussions.microsoft.comwrote in message
news:2050EE11-3FCD-4A27-BAC0-179189066232@microsoft.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

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

Post your reply

Help answer this question



Didn't find the answer to your C# / C Sharp question?

You can also browse similar questions: C# / C Sharp