private void Subscribe() { // Note: for the application hook, use the Hook.AppEvents() instead m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.KeyPress += GlobalHookKeyPress; //Detect Ctrl + Shift + F11 m_GlobalHook.OnCombination(new Dictionary <Combination, Action>() { { Combination.FromString("Control+Shift+F11"), GlobalHookKeyCtrlShiftF1Press }, }); //Detect F12 m_GlobalHook.OnCombination(new Dictionary <Combination, Action>() { { Combination.FromString("F12"), GlobalHookKeyCtrlF1Press }, }); }
private void SetUpHotKeys() { _globalHook = Hook.GlobalEvents(); _globalHook.MouseDown += (o, e) => { if (e.X < Left || e.X > Left + Width || e.Y < Top || e.Y > Top + Height) { HideMainWindow(); } }; _globalHook.OnCombination(new Dictionary <Combination, Action>() { { Combination.FromString("Pause"), () => { CopyFromActiveProgram(); ShowMainWindow(); } }, { Combination.FromString("Escape"), HideMainWindow } }); }
private void InitializeHooks() { _hook = Hook.GlobalEvents(); var d = new Dictionary <Combination, Action> { { Combination.FromString(_settings.ToggleEmulationKeyCombination), HandleToggleEmulationKeyCombination } }; _hook.OnCombination(d); }
private void cookingTimer_Load(object sender, EventArgs e) { _keyboardEvents = Hook.GlobalEvents(); var fkeys = new Dictionary <Combination, Action>(); fkeys.Add(Combination.TriggeredBy(Keys.F9), F9Press); //Fish fkeys.Add(Combination.TriggeredBy(Keys.F10), F10Press); //Trophy Fish fkeys.Add(Combination.TriggeredBy(Keys.F11), F11Press); //Meat & shark fkeys.Add(Combination.TriggeredBy(Keys.F12), F12Press); //Meg & Kraken _keyboardEvents.OnCombination(fkeys); }
private void SubscribeHotKeys() { UnsubscribeHotKeys(); _keybindEvents = Hook.GlobalEvents(); var actions = new Dictionary <Combination, Action>() { { Combination.FromString("Shift+Up"), async() => await KeyBindMoveUp() }, { Combination.FromString("Shift+Down"), async() => await KeyBindMoveDown() } }; _keybindEvents.OnCombination(actions); }
private void SubscribeKeyboardEvents() { _globalHook = Hook.GlobalEvents(); _globalHook.OnCombination(new Dictionary <Combination, Action> { { Combination.FromString("Alt+CapsLock"), () => { Switch(); var processId = GetForegroundProcessId(); Activate(); FocusProcess(processId); } } }); }
public void InstallHooks() { if (_globalHook != null) // hooks are already installed { return; } var combinations = new Dictionary <Combination, Action>(); try { if (!string.IsNullOrWhiteSpace(_hotkeyOptions.Start)) { combinations.Add(Combination.FromString(_hotkeyOptions.Start), _player.Start); } if (!string.IsNullOrWhiteSpace(_hotkeyOptions.Next)) { combinations.Add(Combination.FromString(_hotkeyOptions.Next), _player.Next); } if (!string.IsNullOrWhiteSpace(_hotkeyOptions.Previous)) { combinations.Add(Combination.FromString(_hotkeyOptions.Previous), _player.Previous); } } catch (ArgumentException e) { Log.Debug(e, "One of our key combinations is invalid"); throw new ArgumentException("One of our key combinations is invalid", e); } catch (Exception e) { Log.Debug(e, "Unhandled exception"); throw; } foreach (var(key, value) in combinations) { Log.Information("Added combination {@Key} that triggers {@Method}", key.ToString(), value.Method.Name); } _globalHook = Hook.GlobalEvents(); _globalHook.OnCombination(combinations); Log.Information("Installed low-level keyboard hooks"); }
public static void Configure(IToolManager <IProcessTool> tools, IKeyboardMouseEvents events, Action exitAction) { var keyCombinationToActionMap = new Dictionary <Combination, Action> { { Combination.FromString("Control+K+L"), () => { tools.GetByName("desktopKeyHook").Start(); } }, { Combination.FromString("Control+K+J"), () => { tools.GetByName("desktopKeyHook").Stop(); } }, { Combination.FromString("Control+S+D"), () => { tools.GetByName("desktopRecorder").Start(); } }, { Combination.FromString("Control+S+A"), () => { tools.GetByName("desktopRecorder").Stop(); } }, }; events.KeyPress += (o, e) => { if (e.KeyChar == 'q') { exitAction(); } }; events.OnCombination(keyCombinationToActionMap); }
public GameMonitor() { playerKeyBindings = getPlayerKeybindings(); // Key/Mouse combinations to monitor var assignment = new Dictionary <Combination, Action> { }; // Nade cooking key combiantions from player config foreach (var fire in playerKeyBindings["Fire"]) { foreach (var cook in playerKeyBindings["StartCookingThrowable"]) { string keyCombo = fire + "+" + cook; // Add every combination to monitor assignment.Add(Combination.FromString(keyCombo), suicideByNade); } } // Hold interact button event (to detect if player is reviving someone) foreach (var interact in playerKeyBindings["Interact"]) { // Add every combination to monitor assignment.Add(Combination.FromString(interact), holdingInteractButton); } // Install listener m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.OnCombination(assignment); // Set timer to check if player is driving aTimer = new System.Timers.Timer(3000); aTimer.Elapsed += isPlayerDriving; aTimer.AutoReset = true; aTimer.Enabled = true; // Set timer that is used to trigger player to shoot his teammate when reviving reviveTimer = new System.Timers.Timer(7000); reviveTimer.Elapsed += fireeeeeeeeeeeeeeeee; reviveTimer.AutoReset = false; reviveTimer.Enabled = false; }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { IWordCommandsConfig wordCommandsConfig = new WordCommandsConfig(); DocumentActions documentActions = new DocumentActions(wordCommandsConfig); Dictionary <Combination, System.Action> bindings = new Dictionary <Combination, System.Action>() { { wordCommandsConfig.CommentKeyBinding(), // how do I want to handle ab () => { documentActions.CommentLine(GetCurrentRange(Application)); } }, { wordCommandsConfig.UncommentKeyBinding(), () => { documentActions.UncommentLine(GetCurrentRange(Application)); } }, }; keyboardHook = Gma.System.MouseKeyHook.Hook.GlobalEvents(); keyboardHook.OnCombination(bindings); }
private void SetGlobalHookEventCaptureHotkey() { if (!CaptureHotkey.IsValidHotkey(CaptureHotkeyString)) { return; } var onCombinationDictionary = new Dictionary <Combination, Action> { { Combination.FromString(CaptureHotkeyString), () => { if (!_dataOffsetRunning) { SetCaptureMode(); } } } }; _globalHookEvent = Hook.GlobalEvents(); _globalHookEvent.OnCombination(onCombinationDictionary); }
public void Subscribe() { OutputWriter.WriteLine("============================================="); OutputWriter.WriteLine("Open the Avid, and bring it to the foreground."); OutputWriter.WriteLine("Alt+A - Begin Typing."); OutputWriter.WriteLine("Alt+C - Cancel background typing."); OutputWriter.WriteLine("============================================="); // Note: for the application hook, use the Hook.AppEvents() instead m_GlobalHook = Hook.GlobalEvents(); var map = new Dictionary <Combination, Action> { { Combination.FromString("Alt+A"), () => { WorkEngine.Start(); } }, { Combination.FromString("Alt+C"), () => { WorkEngine.Stop(); } }, }; m_GlobalHook.OnCombination(map); m_GlobalHook.MouseDownExt += GlobalHookMouseDownExt; m_GlobalHook.KeyPress += GlobalHookKeyPress; }
public GlobalInputWindows() { m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.KeyPress += HandleInputs; // special hook for F1-F12 keys m_GlobalHook.OnCombination(new Dictionary <Combination, Action>() { { Combination.TriggeredBy(Keys.F1), () => HandleCombinatedInputs("F1") }, { Combination.TriggeredBy(Keys.F2), () => HandleCombinatedInputs("F2") }, { Combination.TriggeredBy(Keys.F3), () => HandleCombinatedInputs("F3") }, { Combination.TriggeredBy(Keys.F4), () => HandleCombinatedInputs("F4") }, { Combination.TriggeredBy(Keys.F5), () => HandleCombinatedInputs("F5") }, { Combination.TriggeredBy(Keys.F6), () => HandleCombinatedInputs("F6") }, { Combination.TriggeredBy(Keys.F7), () => HandleCombinatedInputs("F7") }, { Combination.TriggeredBy(Keys.F8), () => HandleCombinatedInputs("F8") }, { Combination.TriggeredBy(Keys.F9), () => HandleCombinatedInputs("F9") }, { Combination.TriggeredBy(Keys.F10), () => HandleCombinatedInputs("F10") }, { Combination.TriggeredBy(Keys.F11), () => HandleCombinatedInputs("F11") }, { Combination.TriggeredBy(Keys.F12), () => HandleCombinatedInputs("F12") }, }); }
private void TxtHotkey_TextChanged(object sender, EventArgs e) { keyboardEvents?.Dispose(); keyboardEvents = Hook.GlobalEvents(); string hotkey = txtHotkey.Text.Trim(); try { keyboardEvents.OnCombination(new Dictionary <Combination, Action> { { Combination.FromString(hotkey), () => ToggleMagWindow() } }); txtHotkey.ForeColor = Color.Black; Settings.Default.Hotkey = hotkey; tsmiHotkey.Text = "热键:" + hotkey; } catch (ArgumentException) { txtHotkey.ForeColor = Color.Red; } }
public Form_EventFileReader(string Game_Name, string Game_Path) { this.Game_Path = Game_Path; InitializeComponent(); //load presets checkBox_ShowWarnings.Checked = Properties.Settings.Default.Show_warnings; checkBox_ShowErrors.Checked = Properties.Settings.Default.Show_errors; checkBox_ShowNotifications.Checked = Properties.Settings.Default.Show_notifications; checkBox_ShowDebug.Checked = Properties.Settings.Default.Show_debug_info; vibrationEvents = new VibrationEvents(Game_Path); memory_scanner = new Memory_Scanner(Game_Name); eventFileScanner = new EventFileScanner(Game_Path, memory_scanner, vibrationEvents); RecorderOptions options = new RecorderOptions { RecorderMode = RecorderMode.Video, RecorderApi = RecorderApi.WindowsGraphicsCapture, IsThrottlingDisabled = false, IsHardwareEncodingEnabled = true, IsLowLatencyEnabled = false, IsMp4FastStartEnabled = false, IsFragmentedMp4Enabled = false, IsLogEnabled = true, LogSeverityLevel = LogLevel.Debug, LogFilePath = @"C:\Users\jpriv\Desktop\Nieuwe map\", AudioOptions = new AudioOptions { IsAudioEnabled = false, }, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.Quality, Bitrate = 7000 * 1000, Framerate = 60, Quality = 70, IsFixedFramerate = true, EncoderProfile = H264Profile.Main } }; _rec1 = Recorder.CreateRecorder(options); _rec2 = Recorder.CreateRecorder(options); m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.OnCombination(new Dictionary <Combination, Action> { { Combination.TriggeredBy(Keys.PageUp), WaitForRecording }, }); m_GlobalHook.OnCombination(new Dictionary <Combination, Action> { { Combination.TriggeredBy(Keys.Home), WaitForContinuesRecording }, }); m_GlobalHook.OnCombination(new Dictionary <Combination, Action> { { Combination.TriggeredBy(Keys.End), StopRecording }, }); }