I registered a global hot key for the F3 key in the app. The app simply shows the message "Only pressed F3." when I press F3.
But as I keep pressing and holding the F3 key, it shows the message "Only pressed F3." on the screen several times. So instead of doing it once, it's doing it over and over again.
But when I continue to hold down the F3 key, I want it to show a message like "Hold down F3." So I want it to process once, but this time I want it to run a different case.
Below is the code snippet I am dealing with.
namespace WinForms;
public partial class Click : Form
{
[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
public Click()
{
InitializeComponent();
RegisterHotKey(Handle, 3, 0, Keys.F3.GetHashCode());
}
protected override void WndProc(ref Message message)
{
base.WndProc(ref message);
if (message.Msg != 0x0312) return;
var id = message.WParam.ToInt32();
switch (id)
{
case 3:
{
MessageBox.Show(@"Only pressed F3.");
break;
}
}
}
}