比如我的WinForm启动后最小化
然后他有一个Button_Click()事件

MessageBox.Show("程序调用成功");现在要求这个程序运行后
在我的Windows中的任何地方按了[F10]的话
就能调用这个Click()事件谢谢怎么办

解决方案 »

  1.   

    系统热键啊
    大概需要 这么4个
    [DllImport("user32.dll")]
    public static extern UInt32 RegisterHotKey( IntPtr hWnd, UInt32 id, UInt32 fsModifiers, UInt32 vk);
    [DllImport("user32.dll")]
    public static extern UInt32 UnregisterHotKey( IntPtr hWnd, UInt32 id); 
    [DllImport("kernel32.dll")]
    public static extern UInt32 GlobalAddAtom( String lpString );
    [DllImport("kernel32.dll")]
    public static extern UInt32 GlobalDeleteAtom( UInt32 nAtom );baidu一下 满大街都是。我相信楼下会给出搜索结果
      

  2.   


    string strKeys;
            private void Form1_Load(object sender, EventArgs e)
            {            RegisterHotKey(Handle, 100, 0, Keys.F10);        }        [Flags()]
            public enum KeyModifiers
            {
                None = 0,
                Alt = 1,
                Control = 2,
                Shift = 4,
                Windows = 8
            }
            private void ProcessHotkey()//主处理程序
            {
                button2_Click(null, null);
            }        protected override void WndProc(ref Message m)//循环监视Windows消息
            {
                const int WM_HOTKEY = 0x0312;//按快捷键
                switch (m.Msg)
                {
                    case WM_HOTKEY:
                        ProcessHotkey();//调用主处理程序
                        break;
                }
                base.WndProc(ref m);
            }        [DllImport("user32.dll", SetLastError = true)]
            public static extern bool RegisterHotKey(IntPtr hWnd,
                // handle to window 
             int id, // hot key identifier 
             KeyModifiers fsModifiers, // key-modifier options 
             Keys vk // virtual-key code 
            );        [DllImport("user32.dll", SetLastError = true)]
            public static extern bool UnregisterHotKey(IntPtr hWnd,
                // handle to window 
             int id // hot key identifier 
            );
            private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show("ddd");
            }
      

  3.   


    string strKeys;
            private void Form1_Load(object sender, EventArgs e)
            {            RegisterHotKey(Handle, 100, 0, Keys.F10);        }        [Flags()]
            public enum KeyModifiers
            {
                None = 0,
                Alt = 1,
                Control = 2,
                Shift = 4,
                Windows = 8
            }
            private void ProcessHotkey()//主处理程序
            {
                button2_Click(null, null);
            }        protected override void WndProc(ref Message m)//循环监视Windows消息
            {
                const int WM_HOTKEY = 0x0312;//按快捷键
                switch (m.Msg)
                {
                    case WM_HOTKEY:
                        ProcessHotkey();//调用主处理程序
                        break;
                }
                base.WndProc(ref m);
            }        [DllImport("user32.dll", SetLastError = true)]
            public static extern bool RegisterHotKey(IntPtr hWnd,
                // handle to window 
             int id, // hot key identifier 
             KeyModifiers fsModifiers, // key-modifier options 
             Keys vk // virtual-key code 
            );        [DllImport("user32.dll", SetLastError = true)]
            public static extern bool UnregisterHotKey(IntPtr hWnd,
                // handle to window 
             int id // hot key identifier 
            );
            private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show("ddd");
            }
      

  4.   


    LZ把这个在MSDN上搜一下
    或者直接去google搜C#注册系统热键