Link to home
Start Free TrialLog in
Avatar of rushtosachin
rushtosachin

asked on

How to capture Keystrokes in .Net

Hi Guys,
Am wondering if anyone has some code to capture keystrokes from a computer ...like i want to create an executable which logs the key strokes in a text file and mail it to remote server.
ASKER CERTIFIED SOLUTION
Avatar of armoghan
armoghan
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gregasm
gregasm

Are you programming spyware? Your project is scary sounding.

Bad Luck with it!

just kidding =P
If you are using Visual studio.net you can use the key events to detect when an key is pressed.
You can detect  KeyDown, KeyPress and KeyUp in any form or any object like a TextBox, Button, ..
in C# you can do with this:
First declare the event function in the object.

this.txbEnviar.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txbEnviar_KeyPress);

You only have to decalre the actions to be done after the keys are pressed.
                  
private void txbEnviar_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
      if (13 == e.KeyChar)
      {
            //Enter key has been pressed
      }
}