1
I have form more precisely a menu of options and wanted to hide that form when I press the key F1 and show when to squeeze F1 again. I tried to follow this tutorial of the link that uses hook keyboard
.
But when I squeeze F1 it hides, but already shows next without getting hidden. For my case I do not want to use the Event KeyDown
, I need to use this hook.
public Form1()
{
InitializeComponent();
}
globalKeyboardHook gkh = new globalKeyboardHook();
private void Form1_Load(object sender, EventArgs e)
{
gkh.HookedKeys.Add(Keys.F1);
gkh.KeyDown += new KeyEventHandler(gkh_KeyDown);
// gkh.KeyUp += new KeyEventHandler(gkh_KeyUp);
}
void gkh_KeyUp(object sender, KeyEventArgs e)
{
this.Show();
e.Handled = true;
}
void gkh_KeyDown(object sender, KeyEventArgs e)
{
this.Hide();
e.Handled = true;
}
private void Form1_Closing(object sender, EventArgs e)
{
gkh.unhook();
}
F1
is standard key forHELP
, it would not be a mistake to use it like this?– novic