private void ReadKeyboardAction() { KeyboardActionBase action; if (radKeyboardDown.Checked) { action = new KeyDownAction(); } else if (radKeyboardPress.Checked) { action = new KeyPressAction(); } else if (radKeyboardUp.Checked) { action = new KeyUpAction(); } else { throw new ArgumentException("Keyboard event type could not be determined."); } action.KeyCode = (VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), cmbVKC.SelectedValue.ToString()); SetAction = action; }
private void HookManager_KeyUp(object sender, KeyEventArgs e) { try { UpdateWorkingDir(true); lock (_locker) { if (_is_monitoring) { if (HandleModifierKeyUp(e.KeyCode)) { UserAction action = new KeyUpAction(e.KeyCode, _modifiers); //if (e.KeyCode == Keys.RMenu) // MessageBox.Show("woot"); //if (e.KeyChar != char.MinValue && e.KeyChar != '\r' && e.KeyChar != '\b' && e.KeyCode != Keys.Escape && // ((_modifiers == ContextLib.DataContainers.Monitoring.UserAction.Modifiers.None) || // (_modifiers == ContextLib.DataContainers.Monitoring.UserAction.Modifiers.Shift) || // (_modifiers == ContextLib.DataContainers.Monitoring.UserAction.Modifiers.CapsLock) || // (_modifiers == (ContextLib.DataContainers.Monitoring.UserAction.Modifiers.Shift | ContextLib.DataContainers.Monitoring.UserAction.Modifiers.CapsLock)) || // (_modifiers == (ContextLib.DataContainers.Monitoring.UserAction.Modifiers.Alt | ContextLib.DataContainers.Monitoring.UserAction.Modifiers.Ctrl)))) //{ // action = new TypeTextAction(new string(e.KeyChar, 1)); //} //else //{ // if (e.KeyCode == Keys.LMenu || e.KeyCode == Keys.RMenu || // e.KeyCode == Keys.LControlKey || e.KeyCode == Keys.RControlKey || // e.KeyCode == Keys.LShiftKey || e.KeyCode == Keys.RShiftKey || // e.KeyCode == Keys.LWin || e.KeyCode == Keys.RWin || // e.KeyCode == Keys.CapsLock) // { // ContextLib.DataContainers.Monitoring.UserAction.Modifiers mod = UserAction.Modifiers.None; // switch (e.KeyCode) // { // case Keys.LMenu: // mod &= ~UserAction.Modifiers.Alt; // break; // case Keys.RMenu: // mod &= ~UserAction.Modifiers.Alt; // break; // case Keys.LControlKey: // mod &= ~UserAction.Modifiers.Ctrl; // break; // case Keys.RControlKey: // mod &= ~UserAction.Modifiers.Ctrl; // break; // case Keys.LShiftKey: // mod &= ~UserAction.Modifiers.Shift; // break; // case Keys.RShiftKey: // mod &= ~UserAction.Modifiers.Shift; // break; // case Keys.LWin: // mod &= ~UserAction.Modifiers.Win; // break; // case Keys.RWin: // mod &= ~UserAction.Modifiers.Win; // break; // } // action = new KeyUpAction(e.KeyCode, mod); // } // else // { // action = new KeyPressAction(e.KeyCode, _modifiers); // ((KeyPressAction)action).KeyChar = e.KeyChar; // } //} //HandleModifierKeyUp(e.KeyCode); if (_is_recording) { _macro.AddAction(action); } if (!IsBrowsingExplorerWindow(action.Window)) { _actions.AddAction(action); } else { _actions.ValidadeActions(); } NotifyOtherAgents(); _last_user_action = DateTime.Now; } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }