我有这个:
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
private void Form1_Load(object sender, EventArgs e)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "notepad";
info.UseShellExecute = true;
var process = Process.Start(info);
Thread.Sleep(2000);
SetParent(process.MainWindowHandle, this.Handle);
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
MessageBox.Show("asd");
}
现在,每当我在Form1有焦点时按下某个键,它就会检测到它。但是当我开始在记事本中键入文本时 - Form1没有看到我按下的键。如何使Form1能够捕获我按下的键?
答案 0 :(得分:0)
您需要的是键盘记录程序类型的软件。即使表单没有聚焦,它仍然有效。检查此链接。它应该能够帮助你。
http://null-byte.wonderhowto.com/how-to/create-simple-hidden-console-keylogger-c-sharp-0132757/