0
我想在我的應用程序中製作,比當這個應用程序在後臺時,當我點擊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;
}
}
}
}
但不工作:(
你能幫我請
請詳細說明什麼是不工作。 – cadrell0 2012-04-02 13:33:25
這是去內功能WndProc,但從來沒有在9000和9001的情況下 – cadi2108 2012-04-02 13:51:45
我不打算標記爲重複,但這可能是相關的? http://stackoverflow.com/questions/6664420/f10-key-is-not-caught – cadrell0 2012-04-02 14:21:24