private void BtnSave_Click(object sender, EventArgs e) { bool caps = Keybindings.ToggleOnCaps; Keybindings = new Keybinds(); Keybindings.ToggleOnCaps = caps; for (int count = 0; count < CurrRow; count++) { var button = FindButtonByNumber(count); var label = FindLabelFromButton(button); var textbox = FindTextBoxFromButton(button); //We have our objects! if (label.Text != "Audio File") { VirtualKeycodes keycode = (VirtualKeycodes)System.Enum.Parse(typeof(VirtualKeycodes), textbox.Text); bool allowed = true; foreach (var bind in Keybindings.binds) { if (bind.Value == keycode) { allowed = false; MessageBox.Show("You have a duplicate keybinding. This does not work. Please remove it."); } } if (allowed) { Keybindings.binds.Add(label.Text, keycode); } } } File.WriteAllText("./binds.json", JsonConvert.SerializeObject(Keybindings, Formatting.Indented)); }
private async void GlobalKeyHook_OnKeyDown(object sender, GlobalKeyEventArgs e) { tempKey = e.KeyCode; if (e.KeyCode.ToString() == textBox_AzureKeySettingSpeech.Text) { try { SendKeys.Send(await azure.MicrophoneInput(Form1.e_selectionLanguage)); } catch (System.ApplicationException) { printLog(CAzureError.micNotRecognize); } } else if (e.KeyCode.ToString() == textBox_AzureKeySettingToggle.Text) { toogleState = e_currentToggleState.OFF; btn_AzureOff_Click(this, null); } }
private void GlobalKeyHook_OnKeyDown(object sender, GlobalKeyEventArgs e) { returnValue = e.KeyCode; globalKeyHook.Dispose(); this.Close(); }