我想在我的应用程序中制作,而不是当这个应用程序在后台时,当我单击 F10 时,将启动带有循环的功能。
这是我的代码:
namespace test
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
[DllImport("user32.dll")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
public Form1() //(lub Form1_Load(object sender, System.EventArgs e))
{
RegisterHotKey(this.Handle,9000, 2, (int) Keys.F10);
InitializeComponent();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
UnregisterHotKey(this.Handle,9000);
UnregisterHotKey(this.Handle,9001);
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case 0x312:
switch (m.WParam.ToInt32())
{
case 9000:
//code
break;
case 9001:
//code
break;
}
break;
}
}
}
}
但不工作:(
你能帮我吗?