/// <summary> /// Window Process Handler /// </summary> /// <param name="hwnd"></param> /// <param name="msg"></param> /// <param name="wParam"></param> /// <param name="lParam"></param> /// <param name="handled"></param> /// <returns></returns> protected IntPtr WindowProcHandler(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { MessageType msgType = (MessageType)msg; if (msgType == MessageType.WM_HOTKEY) { RhkModifier rhk = (RhkModifier)(lParam.ToInt32() & 0xFFFF); //低双字节 VirtualKeyCode key = (VirtualKeyCode)(lParam.ToInt32() >> 16); //高双字节 key if (rhk == RhkModifier.CONTROL) { if (key == VirtualKeyCode.VK_L) { if (this.WindowState == WindowState.Minimized || this.Visibility == Visibility.Hidden) { this.Show(); this.Activate(); this.WindowState = WindowState.Normal; } else { this.WindowState = WindowState.Minimized; this.Hide(); } } if (key == VirtualKeyCode.VK_M) { // ... } handled = true; } } return(IntPtr.Zero); }
public static extern bool RegisterHotKey(IntPtr hWnd, int id, RhkModifier fsModifiers, VirtualKeyCode vk);