private static void HookSessionOnHookTriggered(object sender, HookEventArgs e) { Console.WriteLine("--- [Hook callback] ---"); Console.WriteLine("[Registers]"); for (int i = 0; i < 9; i++) { var register = (RegisterX86)i; Console.WriteLine("{0}: {1:X8}", register.ToString().ToLowerInvariant(), e.Registers[i]); } var esp = (IntPtr)e.Registers[(int)RegisterX86.Esp]; Console.WriteLine("[Stack]"); var data = _hookSession.ReadMemory(esp, 4 * sizeof(int)); for (int i = 0; i < 4 * sizeof(int); i += sizeof(int)) { Console.WriteLine($"esp+{i:00}: {BitConverter.ToUInt32(data, i):X8}"); } Console.WriteLine("Changing esp+4 to 0x1234"); _hookSession.WriteMemory(esp + 4, BitConverter.GetBytes(0x1234)); Console.WriteLine("--- [End hook callback] ---"); }
/// <summary> /// Handle messages for context menu /// </summary> private void WindowsHookInvoked(object sender, HookEventArgs e) { CWPSTRUCT cwp = (CWPSTRUCT)Marshal.PtrToStructure(e.lParam, typeof(CWPSTRUCT)); if (_oContextMenu2 != null && (cwp.message == (int)WM.INITMENUPOPUP || cwp.message == (int)WM.MEASUREITEM || cwp.message == (int)WM.DRAWITEM)) { if (_oContextMenu2.HandleMenuMsg((uint)cwp.message, cwp.wparam, cwp.lparam) == S_OK) { return; } } if (_oContextMenu3 != null && cwp.message == (int)WM.MENUCHAR) { if (_oContextMenu3.HandleMenuMsg2((uint)cwp.message, cwp.wparam, cwp.lparam, IntPtr.Zero) == S_OK) { return; } } return; }
protected void OnHookInvoked(HookEventArgs e) { if (HookInvoked != null) { HookInvoked(this, e); } }
private bool hookMouse_HookInvoked(object sender, HookEventArgs e) { if (e.wParam == (IntPtr)513 || e.wParam == (IntPtr)519 || (e.wParam == (IntPtr)516 || e.wParam == (IntPtr)161) || (e.wParam == (IntPtr)167 || e.wParam == (IntPtr)164)) { WindowsHook.MSLLHOOKSTRUCT structure = (WindowsHook.MSLLHOOKSTRUCT)Marshal.PtrToStructure(e.lParam, typeof(WindowsHook.MSLLHOOKSTRUCT)); Point p = new Point(structure.pt.x, structure.pt.y); try { if (!this.ActiveDropDown.ClientRectangle.Contains(this.ActiveDropDown.PointToClient(p))) { for (int index1 = this.DropDowns.Count - 2; index1 >= 0; --index1) { Point client = this.DropDowns[index1].PointToClient(p); if (this.DropDowns[index1].ClientRectangle.Contains(client)) { for (int index2 = this.DropDowns.Count - 1; index2 > index1; --index2) { this.DropDowns[index2].ClosePopup(RadPopupCloseReason.Mouse); } return(true); } } this.UnRegisterAllMenus(); } } catch { this.UnRegisterAllMenus(); } } return(true); }
/// <summary> /// the function called for every keypress! /// </summary> /// <param name="code"></param> /// <param name="wParam">the keyboard message WM_Keydown/UP etc</param> /// <param name="lParam">the KBDLLHOOKSTRUCT info</param> /// <returns></returns> private IntPtr HookProcedure(int code, IntPtr wParam, IntPtr lParam) { IntPtr hwnd = IntPtr.Zero; hwnd = win32.GetForegroundWindow(); if (hwnd == _hWnd) //filter messages for our window only! { KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT)); if (_msgFilter.Count == 0 || _msgFilter.Contains((WindowsMessages.WM_MESG)wParam)) { if (_vkcodeFilter.Contains((vkcodes.VKEY)hookStruct.vkCode) || _vkcodeFilter.Count == 0) { //OnHookEvent(); HookEventArgs hookArgs = new HookEventArgs(); hookArgs.Code = code; hookArgs.hookstruct = hookStruct; hookArgs.wParam = wParam; ProcessHookEvent(hookArgs); //forward the key or just discard the keyboard message? if (_consumeKey) { return((IntPtr)1); } } } } return(NativeMethods.CallNextHookEx(_hookDeleg, code, wParam, lParam)); }
protected bool OnHooked(HookEventArgs e) { var handler = Hooked; if (handler != null) return handler(e); else return true; }
private void OnHookKeyDown(object sender, HookEventArgs e) { if (this.dataService.SystemWindow != null) { SystemWindow sysWindow = this.dataService.SystemWindow as SystemWindow; sysWindow.OnHookKeyDownHandler(sender, e); } }
private void OnHookKeyDown(object sender, HookEventArgs e) { if (!keys.Exists(x => x == e.Key)) { keys.Add(e.Key); ShowKeys(); } }
void ProcessHookEvent(HookEventArgs args) { if (HookEvent != null) { //_owner.Invoke(HookEvent(args)); HookEvent(this, args); } }
public void OnMessageReceived() { var handler = MessageReceived; if (handler != null) { var args = new HookEventArgs(HotkeyInfo.Keys); handler.Invoke(this, args); } }
public void TriggerHook(HookEventArgs e) { var handler = _eventManager.GetHandler <EventHandler <HookEventArgs> >(_hookKey); if (handler != null) { handler(this, e); } }
void OnHookKeyDown(object sender, HookEventArgs e) { try { if (Views.MainWindow.IsCommandFocused) { return; } var str = new StringBuilder(); if (e.Control) { str.Append("Ctrl + "); } if (e.Shift) { str.Append("Shift + "); } if (e.Alt) { str.Append("Alt + "); } str.Append(KeyInterop.KeyFromVirtualKey((int)e.Key)); if (!Commands.Any(x => x.Model.Hotkey == str.ToString())) { return; } foreach (var cmd in Commands.Where(x => x.Model.Hotkey == str.ToString())) { if (cmd.Model.IsLocal && cmd.Model.IsRepeat && cmd.Model.TimeReminder.TotalSeconds > 0) { RepeatMessageHandler(cmd.Model); } else if (cmd.Model.TimeReminder.TotalSeconds > 0) { DelayedMessageHandler(cmd.Model); } else if (IsServerConnected) { m_Client.SendDataToServer(Model.User, cmd.Model.Message, (int)cmd.Model.MessageColor); } else { ProcessNewMessage(string.Empty, cmd.Model.Message, (int)cmd.Model.MessageColor); } } } catch (Exception ex) { Log.Message(ex.ToString()); } }
public KeyboardHookStruct(HookEventArgs e) { KeyboardHookStruct khs = (KeyboardHookStruct)Marshal.PtrToStructure(e.LParam, typeof(KeyboardHookStruct)); virtualKey = khs.virtualKey; scanCode = khs.scanCode; flags = khs.flags; time = khs.time; dwExtraInfo = khs.dwExtraInfo; }
private void OnHookKeyDown(object sender, HookEventArgs e) { SetKeyDown(e.Key); if (IsKeyDown(Key.PrintScreen)) { var screenCut = new ScreenCut() { Topmost = true }; screenCut.Activate(); screenCut.Closing += delegate { SetKeyUp(Key.PrintScreen); }; screenCut.ShowDialog(); } else { if (keys.Count == 2 && IsKeyDown(Key.LeftAlt)) { var _key = Win32Api.GetCharFromKey(e.Key).ToString().ToUpper(); if (string.IsNullOrWhiteSpace(_key)) { return; } var offset = 0.0; var scrollViewer = ControlsHelper.FindChild <ScrollViewer>(AppSwitchList, "PART_ScrollViewer"); var elementList = ControlsHelper.FindVisualChildren <Border>(AppSwitchList).ToList(); var isFind = false; for (var i = 0; i < elementList.Count; i++) { var element = elementList[i]; if (isFind) { break; } if (element.Tag != null) { offset += element.ActualHeight; if (element.Tag.ToString().Equals(_key)) { offset -= element.ActualHeight; scrollViewer.ScrollToVerticalOffset(offset); isFind = true; } } } KeyDownText.Text = _key; KeyDownPanel.Visibility = Visibility.Visible; } } }
private void I(object sender, HookEventArgs e) { MSLLHOOKSTRUCT st = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(e.lParam, typeof(MSLLHOOKSTRUCT)); _prevMPoint = _prevMPoint ?? st.pt; OnEventRaised(new MouseEventArgs() { Message = (MouseMessage)e.wParam, Point = st.pt, ExtraInfo = st.dwExtraInfo, WheelDelta = (MouseMessage)e.wParam == MouseMessage.WM_MOUSEWHEEL ? st.mouseData >> 16 & 0xFF : 0, MovePath = (MouseMessage)e.wParam == MouseMessage.WM_MOUSEMOVE ? Math.Sqrt(Math.Pow(_prevMPoint.X - st.pt.X, 2) + Math.Pow(_prevMPoint.Y - st.pt.Y, 2)) / (_dpi / 2.54) : 0 }); _prevMPoint = st.pt; }
// Default filter function public IntPtr CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) return NativeMethods.CallNextHookEx(m_hHook, code, wParam, lParam); // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.HookCode = code; e.wParam = wParam; e.lParam = lParam; OnHookInvoked(e); // Yield to the next hook in the chain return NativeMethods.CallNextHookEx(m_hHook, code, wParam, lParam); }
// Windows hook event handler private void HookEventHandler(object sender, HookEventArgs e) { Win32.Msgs msg = (Win32.Msgs)Marshal.ReadInt32(e.lParam, IntPtr.Size * 3); if (msg == Win32.Msgs.WM_KILLFOCUS) { IntPtr wParam = Marshal.ReadIntPtr(e.lParam, IntPtr.Size * 2); DockPane pane = GetPaneFromHandle(wParam); if (pane == null) RefreshActiveWindow(); } else if (msg == Win32.Msgs.WM_SETFOCUS) RefreshActiveWindow(); }
protected virtual bool OnKeyboardEvent(HookEventArgs args) { if (args is null) { return(false); } WM wParam = (WM)args.wParam.ToInt32(); var hookInfo = Marshal.PtrToStructure <KBDLLHOOKSTRUCT>(args.lParam); var key = (Keys)hookInfo.vkCode; bool alt = IsKeyPressed(Keys.Menu); bool control = IsKeyPressed(Keys.ControlKey); return(_keyboadHandler.HandleKey(_handler, new KeyboardParam(wParam == WM.KEYUP, alt, control, key))); }
void OnHookInvoked(object sender, HookEventArgs e) { if ((e.WParam == WM_KEYDOWN || e.WParam == WM_SYSKEYDOWN) && KeyDown != null) { KeyboardHookStruct khs = new KeyboardHookStruct(e); KeyEventArgsEx kea = new KeyEventArgsEx(khs.virtualKey, Control.ModifierKeys, khs.scanCode); KeyDown(sender, kea); e.Handled = kea.Handled; } else if ((e.WParam == WM_KEYUP || e.WParam == WM_SYSKEYUP) && KeyUp != null) { KeyboardHookStruct khs = new KeyboardHookStruct(e); KeyEventArgsEx kea = new KeyEventArgsEx(khs.virtualKey, Control.ModifierKeys, khs.scanCode); KeyUp(sender, kea); e.Handled = kea.Handled; } }
void HookEventHandler(object sender, HookEventArgs e) { var msg = (Msgs)Marshal.ReadInt32(e.lParam, IntPtr.Size * 3); if (msg == Msgs.WM_KILLFOCUS) { var wParam = Marshal.ReadIntPtr(e.lParam, IntPtr.Size * 2); var pane = GetPaneFromHandle(wParam); if (pane == null) { RefreshActiveWindow(); } } else if (msg == Msgs.WM_SETFOCUS) { RefreshActiveWindow(); } }
// ************************************************************************ // ************************************************************************ // Default filter function protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) { return(CallNextHookEx(m_hhook, code, wParam, lParam)); } // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.HookCode = code; e.wParam = wParam; e.lParam = lParam; OnHookInvoked(e); // Yield to the next hook in the chain return(CallNextHookEx(m_hhook, code, wParam, lParam)); }
private void OnClassUpdated(object sender, HookEventArgs args) { Debugger.WriteLine("Updating maid and/or yotogi class info."); MaidInfo maid = SelectedMaid; if (maid == null) { Debugger.WriteLine(LogLevel.Warning, "Maid is NULL!"); return; } if (maid.Maid != args.CallerMaid) { Debugger.WriteLine(LogLevel.Warning, "Caller maid is not the selected one! Aborting..."); return; } if (valueUpdateQueue[currentQueue].ContainsKey(args.Tag)) { Debugger.WriteLine(LogLevel.Error, "Tag already in update queue! Aborting..."); return; } switch (args.Tag) { case MaidChangeType.MaidClassType: valueUpdateQueue[currentQueue].Add(args.Tag, () => maid.UpdateMaidClasses()); break; case MaidChangeType.YotogiClassType: valueUpdateQueue[currentQueue].Add(args.Tag, () => maid.UpdateYotogiClasses()); break; case MaidChangeType.MaidAndYotogiClass: valueUpdateQueue[currentQueue].Add( args.Tag, () => { maid.UpdateMaidBonusValues(); maid.UpdateMaidClasses(); maid.UpdateYotogiClasses(); }); break; } }
// Default filter function private IntPtr CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) { return(NativeMethods.CallNextHookEx(_mHHook, code, wParam, lParam)); } // Let clients determine what to do var e = new HookEventArgs { HookCode = code, WParam = wParam, LParam = lParam }; OnHookInvoked(e); // Yield to the next hook in the chain return(NativeMethods.CallNextHookEx(_mHHook, code, wParam, lParam)); }
// Default filter function public IntPtr CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { // System.Diagnostics.Debug.WriteLine("CoreHookProc"); if (code < 0) { return(NativeMethods.CallNextHookEx(m_hHook, code, wParam, lParam)); } // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.HookCode = code; e.wParam = wParam; e.lParam = lParam; OnHookInvoked(e); // Yield to the next hook in the chain return(NativeMethods.CallNextHookEx(m_hHook, code, wParam, lParam)); }
private bool hookMouse_HookInvoked(object sender, HookEventArgs e) { if (e.wParam == (IntPtr)NativeMethods.WM_LBUTTONDOWN || e.wParam == (IntPtr)NativeMethods.WM_MBUTTONDOWN || e.wParam == (IntPtr)NativeMethods.WM_RBUTTONDOWN || e.wParam == (IntPtr)NativeMethods.WM_NCLBUTTONDOWN || e.wParam == (IntPtr)NativeMethods.WM_NCMBUTTONDOWN || e.wParam == (IntPtr)NativeMethods.WM_NCRBUTTONDOWN) { WindowsHook.MSLLHOOKSTRUCT hookStruct = (WindowsHook.MSLLHOOKSTRUCT)Marshal.PtrToStructure(e.lParam, typeof(WindowsHook.MSLLHOOKSTRUCT)); Point point = new Point(hookStruct.pt.x, hookStruct.pt.y); try { if (!ActiveDropDown.ClientRectangle.Contains(ActiveDropDown.PointToClient(point))) { for (int i = DropDowns.Count - 2; i >= 0; i--) { Point p = DropDowns[i].PointToClient(point); if (DropDowns[i].ClientRectangle.Contains(p)) { for (int k = DropDowns.Count - 1; k > i; k--) { DropDowns[k].ClosePopup(RadPopupCloseReason.Mouse); } return(true); } } UnRegisterAllMenus(); } } catch { UnRegisterAllMenus(); } } return(true); }
void OnHookKeyDown(object sender, HookEventArgs e) { KeyCombo hookedCombo = new KeyCombo(e.Key, e.Control, e.Alt, e.Shift); if (hookedCombo.key == Keys.S && hookedCombo.Alt && hookedCombo.Shift && !hookedCombo.Control) { soundManager.StopAllSounds(); } else { foreach (KeyBindWithSounds bind in allBinds) { if (bind.keyCombo.Equals(hookedCombo)) { foreach (string sound in bind.sounds) { PlaySound(sound); } } } } }
/// <summary> /// Get modifier string consisting of Alt, Ctrl, Shift and Caps Lock /// </summary> /// <param name="ha">HookEventArgs object</param> /// <returns>Modifier string</returns> public static string GetModifierString(HookEventArgs ha) { string str = ""; if (ha.Alt) { str += "Alt + "; } if (ha.Control) { str += "Ctrl + "; } if (ha.Shift) { str += "Shift + "; } if (ha.CapsLock) { str += "CapsLock + "; } return(str.TrimEnd(new char[] { ' ', '+' })); }
private static void HookSessionOnHookTriggered(object sender, HookEventArgs e) { Console.WriteLine("MessageBoxA was called!"); var esp = (IntPtr)e.Registers[(int)RegisterX86.Esp]; var rawStackData = _hookSession.ReadMemory(esp, 5 * sizeof(uint)); var stackEntries = new uint[5]; for (int i = 0; i < stackEntries.Length; i++) { stackEntries[i] = BitConverter.ToUInt32(rawStackData, i * sizeof(int)); } var message = BytesToZeroTerminatedString(_hookSession.ReadMemory((IntPtr)stackEntries[2], 100)); var title = BytesToZeroTerminatedString(_hookSession.ReadMemory((IntPtr)stackEntries[3], 100)); Console.WriteLine("Arguments:"); Console.WriteLine($"- hWnd: {stackEntries[1]:X8}"); Console.WriteLine($"- lpText: \"{message}\""); Console.WriteLine($"- lpCaption: \"{title}\""); Console.WriteLine($"- uType: {stackEntries[4]:X8}"); }
/// <summary> /// LocalWindowsHook.HookInvoked event callback, called by LocalWindowsHook /// when a message is received. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LocalWindowsHook_HookInvoked(object sender, HookEventArgs e) { if (e.HookCode >= 0 && new IntPtr(WindowMessage.PM_REMOVE) == e.wParam) { // Copy the message to a local int variable var msg = (uint)Marshal.ReadInt32(e.lParam, Marshal.OffsetOf(typeof(WindowsInterop.MSG), "Msg").ToInt32()); // Don't translate non-input events. if (msg >= WindowMessage.WM_KEYFIRST && msg <= WindowMessage.WM_KEYLAST) { if (WindowsInterop.IsDialogMessage(m_Control.Handle, e.lParam) != 0) { // The value returned from this hook is ignored, // and it cannot be used to tell Windows the message has been handled. // To avoid further processing, convert the message to WM_NULL // before returning. var type = typeof(WindowsInterop.MSG); Marshal.WriteInt32(e.lParam, Marshal.OffsetOf(type, "Msg").ToInt32(), WindowMessage.WM_NULL); Marshal.WriteInt32(e.lParam, Marshal.OffsetOf(type, "wParam").ToInt32(), 0); Marshal.WriteInt32(e.lParam, Marshal.OffsetOf(type, "lParam").ToInt32(), 0); } } } }
private static int HookProcedure(int code, IntPtr wParam, IntPtr lParam) { KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT)); if (code < 0) { return(1); //CallNextHookEx(hookDeleg, code, wParam, lParam); } if (code >= 0 && wParam == (IntPtr)WM_KEYDOWN) { // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.Code = code; e.wParam = wParam; e.lParam = lParam; KeyBoardInfo keyInfo = new KeyBoardInfo(0); keyInfo.vkCode = hookStruct.vkCode; keyInfo.scanCode = hookStruct.scanCode; //MessageBox.Show(""); OnHookEvent(e, keyInfo); } // Yield to the next hook in the chain return(1);//CallNextHookEx(hookDeleg, code, wParam, lParam); }
private void OnHookKeyDown(object sender, HookEventArgs e) { SetKeyDown(e.Key); if (keys.Count == 2 && IsKeyDown(Key.LeftAlt)) { var _key = Win32Api.GetCharFromKey(e.Key).ToString().ToUpper(); if (string.IsNullOrWhiteSpace(_key)) { return; } double offset = 0.0; ScrollViewer scrollViewer = ControlsHelper.FindChild <ScrollViewer>(this.AppSwitchList, "PART_ScrollViewer"); var elementList = ControlsHelper.FindVisualChildren <Border>(this.AppSwitchList).ToList(); bool isFind = false; for (int i = 0; i < elementList.Count; i++) { var element = elementList[i]; if (isFind) { break; } if (element.Tag != null) { offset += element.ActualHeight; if (element.Tag.ToString().Equals(_key)) { offset -= element.ActualHeight; scrollViewer.ScrollToVerticalOffset(offset); isFind = true; } } } this.KeyDownText.Text = _key; this.KeyDownPanel.Visibility = Visibility.Visible; } }
private static bool HookerKeyboard_Hooked(HookEventArgs e) { throw new System.NotImplementedException(); }
private void OnHookKeyUp(object sender, HookEventArgs e) { SetKeyUp(e.Key); KeyDownPanel.Visibility = Visibility.Collapsed; }
// ************************************************************************ // ************************************************************************ // Default filter function protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { this.bCallNextHook = true; if (code < 0) return CallNextHookEx(m_hhook, code, wParam, lParam); // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.HookCode = code; e.wParam = wParam; e.lParam = lParam; OnHookInvoked(e); // Yield to the next hook in the chain if (this.bCallNextHook) return CallNextHookEx(m_hhook, code, wParam, lParam); else return -1; }
// ************************************************************************ // ************************************************************************ // Handles the hook event private void CbtHookInvoked(object sender, HookEventArgs e) { CbtHookAction code = (CbtHookAction)e.HookCode; IntPtr wParam = e.wParam; IntPtr lParam = e.lParam; // Handle hook events (only a few of available actions) switch (code) { case CbtHookAction.HCBT_CREATEWND: HandleCreateWndEvent(wParam, lParam); break; case CbtHookAction.HCBT_DESTROYWND: HandleDestroyWndEvent(wParam, lParam); break; case CbtHookAction.HCBT_ACTIVATE: HandleActivateEvent(wParam, lParam); break; } return; }
public void OnHookKeyDownHandler(object sender, HookEventArgs e) { bool singleCutScreen = e.Key == DataModel.Instance.CutScreenKey; bool ctrlCutScreen = (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && e.Key == DataModel.Instance.CutScreenKey; bool altCutScreen = (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && e.Key == DataModel.Instance.CutScreenKey; bool shiftCutScreen = (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None && e.Key == DataModel.Instance.CutScreenKey; bool ctrlAltCutScreen = (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && e.Key == DataModel.Instance.CutScreenKey; bool ctrlShiftCutScreen = (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None && e.Key == DataModel.Instance.CutScreenKey; bool altShiftCutScreen = (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None && e.Key == DataModel.Instance.CutScreenKey; bool singlePickupMsg = e.Key == DataModel.Instance.PickUpMsgKey; bool ctrlPickupMsg = (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && e.Key == DataModel.Instance.PickUpMsgKey; bool altPickupMsg = (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && e.Key == DataModel.Instance.PickUpMsgKey; bool shiftPickupMsg = (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None && e.Key == DataModel.Instance.PickUpMsgKey; bool ctrlAltPickupMsg = (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && e.Key == DataModel.Instance.PickUpMsgKey; bool ctrlShiftPickupMsg = (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None && e.Key == DataModel.Instance.PickUpMsgKey; bool altShiftPickupMsg = (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None && e.Key == DataModel.Instance.PickUpMsgKey; try { if (DataModel.Instance.IsSetHotKey) { if (WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Focus()) { if (e.Key == Keys.F1 || e.Key == Keys.F2 || e.Key == Keys.F3 || e.Key == Keys.F4 || e.Key == Keys.F5 || e.Key == Keys.F6 || e.Key == Keys.F7 || e.Key == Keys.F8 || e.Key == Keys.F9 || e.Key == Keys.F10 || e.Key == Keys.F11 || e.Key == Keys.F12) { if (e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = e.Key.ToString(); Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = e.Key.ToString(); Settings.Default.CutScreenType = 1; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; Settings.Default.Save(); } } if (e.Key == Keys.Q || e.Key == Keys.W || e.Key == Keys.E || e.Key == Keys.R || e.Key == Keys.T || e.Key == Keys.Y || e.Key == Keys.U || e.Key == Keys.I || e.Key == Keys.O || e.Key == Keys.P || e.Key == Keys.A || e.Key == Keys.S || e.Key == Keys.D || e.Key == Keys.F || e.Key == Keys.G || e.Key == Keys.H || e.Key == Keys.J || e.Key == Keys.K || e.Key == Keys.L || e.Key == Keys.Z || e.Key == Keys.X || e.Key == Keys.C || e.Key == Keys.V || e.Key == Keys.B || e.Key == Keys.N || e.Key == Keys.M) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + " + e.Key.ToString(); }; Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = "Ctrl + Alt + " + e.Key.ToString(); Settings.Default.CutScreenType = 3; Settings.Default.CutScreenCAS = 1; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; DataModel.Instance.CutScreenCAS = Settings.Default.CutScreenCAS; Settings.Default.Save(); } } if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { if (e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = e.Key.ToString().Substring(1, 1); Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = e.Key.ToString().Substring(1, 1); Settings.Default.CutScreenType = 1; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; Settings.Default.Save(); } } if (e.Key == Keys.NumPad0 || e.Key == Keys.NumPad1 || e.Key == Keys.NumPad2 || e.Key == Keys.NumPad3 || e.Key == Keys.NumPad4 || e.Key == Keys.NumPad5 || e.Key == Keys.NumPad6 || e.Key == Keys.NumPad7 || e.Key == Keys.NumPad8 || e.Key == Keys.NumPad9) { if (e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = e.Key.ToString(); Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = e.Key.ToString(); Settings.Default.CutScreenType = 1; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; Settings.Default.Save(); } } if (e.Key == Keys.Home || e.Key == Keys.End || e.Key == Keys.Insert || e.Key == Keys.Prior || e.Key == Keys.Next) { if (e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = e.Key.ToString(); Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = e.Key.ToString(); Settings.Default.CutScreenType = 1; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + " + e.Key.ToString(); }; Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = "Ctrl + " + e.Key.ToString(); Settings.Default.CutScreenType = 2; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + " + e.Key.ToString(); }; Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = "Alt + " + e.Key.ToString(); Settings.Default.CutScreenType = 2; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Shift + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Shift + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Shift + " + e.Key.ToString(); }; Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = "Shift + " + e.Key.ToString(); Settings.Default.CutScreenType = 2; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.LShiftKey || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == Keys.RShiftKey || e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + " + e.Key.ToString(); } WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Alt + " + e.Key.ToString(); } }; Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text; Settings.Default.CutScreenType = 3; Settings.Default.CutScreenCAS = 1; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; DataModel.Instance.CutScreenCAS = Settings.Default.CutScreenCAS; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.LShiftKey || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == Keys.RShiftKey || e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Shift + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Shift + " + e.Key.ToString(); } WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Ctrl + Shift + " + e.Key.ToString(); } }; Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text; Settings.Default.CutScreenType = 3; Settings.Default.CutScreenCAS = 2; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; DataModel.Instance.CutScreenCAS = Settings.Default.CutScreenCAS; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.LShiftKey || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == Keys.RShiftKey || e.Key == DataModel.Instance.PickUpMsgKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + Shift + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "无"; }; } else { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + Shift + " + e.Key.ToString(); } WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.KeyUp += delegate { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text = "Alt + Shift + " + e.Key.ToString(); } }; Settings.Default.CutScreen = e.Key; Settings.Default.CutScreenString = WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxCut.Text; Settings.Default.CutScreenType = 3; Settings.Default.CutScreenCAS = 3; DataModel.Instance.CutScreenKey = Settings.Default.CutScreen; DataModel.Instance.CutScreenType = Settings.Default.CutScreenType; DataModel.Instance.CutScreenCAS = Settings.Default.CutScreenCAS; Settings.Default.Save(); } } } if (WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Focus()) { if (e.Key == Keys.F1 || e.Key == Keys.F2 || e.Key == Keys.F3 || e.Key == Keys.F4 || e.Key == Keys.F5 || e.Key == Keys.F6 || e.Key == Keys.F7 || e.Key == Keys.F8 || e.Key == Keys.F9 || e.Key == Keys.F10 || e.Key == Keys.F11 || e.Key == Keys.F12) { if (e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = e.Key.ToString(); Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = e.Key.ToString(); Settings.Default.PickUpMsgType = 1; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; Settings.Default.Save(); } } if (e.Key == Keys.Q || e.Key == Keys.W || e.Key == Keys.E || e.Key == Keys.R || e.Key == Keys.T || e.Key == Keys.Y || e.Key == Keys.U || e.Key == Keys.I || e.Key == Keys.O || e.Key == Keys.P || e.Key == Keys.A || e.Key == Keys.S || e.Key == Keys.D || e.Key == Keys.F || e.Key == Keys.G || e.Key == Keys.H || e.Key == Keys.J || e.Key == Keys.K || e.Key == Keys.L || e.Key == Keys.Z || e.Key == Keys.X || e.Key == Keys.C || e.Key == Keys.V || e.Key == Keys.B || e.Key == Keys.N || e.Key == Keys.M) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + " + e.Key.ToString(); }; Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = "Ctrl + Alt + " + e.Key.ToString(); Settings.Default.PickUpMsgType = 3; Settings.Default.PickUpMsgCAS = 1; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; DataModel.Instance.PickUpMsgCAS = Settings.Default.PickUpMsgCAS; Settings.Default.Save(); } } if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { if (e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = e.Key.ToString().Substring(1, 1); Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = e.Key.ToString().Substring(1, 1); Settings.Default.PickUpMsgType = 1; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; Settings.Default.Save(); } } if (e.Key == Keys.NumPad0 || e.Key == Keys.NumPad1 || e.Key == Keys.NumPad2 || e.Key == Keys.NumPad3 || e.Key == Keys.NumPad4 || e.Key == Keys.NumPad5 || e.Key == Keys.NumPad6 || e.Key == Keys.NumPad7 || e.Key == Keys.NumPad8 || e.Key == Keys.NumPad9) { if (e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = e.Key.ToString(); Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = e.Key.ToString(); Settings.Default.PickUpMsgType = 1; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; Settings.Default.Save(); } } if (e.Key == Keys.Home || e.Key == Keys.End || e.Key == Keys.Insert || e.Key == Keys.Prior || e.Key == Keys.Next) { if (e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = ""; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = e.Key.ToString(); Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = e.Key.ToString(); Settings.Default.PickUpMsgType = 1; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + " + e.Key.ToString(); }; Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = "Ctrl + " + e.Key.ToString(); Settings.Default.PickUpMsgType = 2; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + " + e.Key.ToString(); }; Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = "Alt + " + e.Key.ToString(); Settings.Default.PickUpMsgType = 2; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Shift + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Shift + " + e.Key.ToString(); WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Shift + " + e.Key.ToString(); }; Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = "Shift + " + e.Key.ToString(); Settings.Default.PickUpMsgType = 2; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.LShiftKey || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == Keys.RShiftKey || e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + " + e.Key.ToString(); } WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Alt + " + e.Key.ToString(); } }; Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text; Settings.Default.PickUpMsgType = 3; Settings.Default.PickUpMsgCAS = 1; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; DataModel.Instance.PickUpMsgCAS = Settings.Default.PickUpMsgCAS; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.LShiftKey || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == Keys.RShiftKey || e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Shift + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Shift + " + e.Key.ToString(); } WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Ctrl + Shift + " + e.Key.ToString(); } }; Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text; Settings.Default.PickUpMsgType = 3; Settings.Default.PickUpMsgCAS = 2; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; DataModel.Instance.PickUpMsgCAS = Settings.Default.PickUpMsgCAS; Settings.Default.Save(); } } if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None && (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None) { if (e.Key == Keys.LControlKey || e.Key == Keys.LMenu || e.Key == Keys.LWin || e.Key == Keys.LShiftKey || e.Key == Keys.RControlKey || e.Key == Keys.RMenu || e.Key == Keys.RWin || e.Key == Keys.RShiftKey || e.Key == DataModel.Instance.CutScreenKey) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + Shift + "; WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "无"; }; } else { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + Shift + " + e.Key.ToString(); } WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.KeyUp += delegate { if (e.Key == Keys.D0 || e.Key == Keys.D1 || e.Key == Keys.D2 || e.Key == Keys.D3 || e.Key == Keys.D4 || e.Key == Keys.D5 || e.Key == Keys.D6 || e.Key == Keys.D7 || e.Key == Keys.D8 || e.Key == Keys.D9) { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + Shift + " + e.Key.ToString().Substring(1, 1); } else { WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text = "Alt + Shift + " + e.Key.ToString(); } }; Settings.Default.PickupMsg = e.Key; Settings.Default.PickupMsgString = WindowModel.Instance.SystemSettingWindow.hotkeySetting.tbxRecover.Text; Settings.Default.PickUpMsgType = 3; Settings.Default.PickUpMsgCAS = 3; DataModel.Instance.PickUpMsgKey = Settings.Default.PickupMsg; DataModel.Instance.PickUpMsgType = Settings.Default.PickUpMsgType; DataModel.Instance.PickUpMsgCAS = Settings.Default.PickUpMsgCAS; Settings.Default.Save(); } } } } if (this.sessionService.IsLogin) { switch (DataModel.Instance.CutScreenType) { case 1: if (singleCutScreen) { this.AllowCutScreen(); } break; case 2: if (ctrlCutScreen) { this.AllowCutScreen(); } if (altCutScreen) { this.AllowCutScreen(); } if (shiftCutScreen) { this.AllowCutScreen(); } break; case 3: switch (DataModel.Instance.CutScreenCAS) { case 1: if (ctrlAltCutScreen) { this.AllowCutScreen(); } break; case 2: if (ctrlShiftCutScreen) { this.AllowCutScreen(); } break; case 3: if (altShiftCutScreen) { this.AllowCutScreen(); } break; } break; } switch (DataModel.Instance.PickUpMsgType) { case 1: if (singlePickupMsg) { this.AllowPickup(); } break; case 2: if (ctrlPickupMsg) { this.AllowPickup(); } if (altPickupMsg) { this.AllowPickup(); } if (shiftPickupMsg) { this.AllowPickup(); } break; case 3: switch (DataModel.Instance.PickUpMsgCAS) { case 1: if (ctrlAltPickupMsg) { this.AllowPickup(); } break; case 2: if (ctrlShiftPickupMsg) { this.AllowPickup(); } break; case 3: if (altShiftPickupMsg) { this.AllowPickup(); } break; } break; } } } catch (System.Exception ex) { this.logger.Error(ex.ToString()); } }
protected void OnHookInvoked(HookEventArgs e) { if (HookInvoked != null) HookInvoked(this, e); }
// Default filter function public IntPtr CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) return NativeMethods.CallNextHookEx(this._mHHook, code, wParam, lParam); // Let clients determine what to do var e = new HookEventArgs { HookCode = code, wParam = wParam, lParam = lParam }; this.OnHookInvoked(e); // Yield to the next hook in the chain return NativeMethods.CallNextHookEx(this._mHHook, code, wParam, lParam); }
bool hook_HookEvent(HookEventArgs e, KeyBoardInfo keyBoardInfo) { if(keyBoardInfo.vkCode == 117) { if(e.wParam == volumeUp) { MainMap.Zoom = (int) (MainMap.Zoom) + 1; } } else if(keyBoardInfo.vkCode == 118) { if(e.wParam == volumeUp) { MainMap.Zoom = (int) (MainMap.Zoom) - 1; } } return true; }