I have a text box on a form that is incremented each time an alt and print screen key are pressed, and specifically on the up of the print screen key. This all works fine. But what I need to accomplish is to keep that happening even when the focus has changed. Below is my code so far: I have been told to create a hook for this as it's outside of my application so any help on this would be greatly appreciated...Thanks
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
{
}
}
}