我在表单上有一个文本框,每次使用alt和打印屏幕键时都会递增 按下,特别是打印屏幕键的上方。一切正常。但是什么 我需要完成的是即使焦点发生变化也能保持这种状态。下面 是我的代码到目前为止:我被告知要为此创建一个钩子,因为它在我的应用程序之外,所以对此的任何帮助将不胜感激...谢谢
public Form2()
{
InitializeComponent();
this.KeyUp += new KeyEventHandler(Form2_KeyUp);
}
public void Form2_KeyUp(object sender, KeyEventArgs e)
{
//If the Alt key was pressed and the PrintScreen key was the one released, bump
//the counter and update the textbox.
if (e.Alt && (e.KeyCode == Keys.PrintScreen))
count++;
try
{
if (count == 0)
textBox1.Text = "0";
else
{
textBox1.Text = ("" + count);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
}
}
}