Exemplo n.º 1
0
        static private bool InstallHotKeyHook(HotKeyUtil hk)//安装热键处理挂钩
        {
            //获得消息源
            HwndSource source = HwndSource.FromHwnd(hk.handle);

            //挂接事件
            source.AddHook(HotKeyUtil.HotKeyHook);
            return(true);
        }
Exemplo n.º 2
0
 static private IntPtr HotKeyHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)//热键处理过程
 {
     if (msg == WM_HOTKEY)
     {
         HotKeyUtil hk = (HotKeyUtil)KeyPair[(int)wParam];
         if (hk.OnHotKey != null)
         {
             hk.OnHotKey();
         }
     }
     return(IntPtr.Zero);
 }