private void textBox1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (this.Key2.Content.Equals("<New Key>")) { this.Key2.Content = e.Key.ToString(); } if (VKConverter.getUINT(this.Key2.Content.ToString()) == 0x00) { System.Windows.MessageBox.Show("This Key can't be used on hot key."); this.Key2.Content = Key2_Value; } }
public static void RegisterHotKey() { String appPath = System.Windows.Forms.Application.StartupPath; appPath = appPath + "\\Drag And Drop.exe"; Configuration configuration = ConfigurationManager.OpenExeConfiguration(appPath); var helper = new WindowInteropHelper(Application.Current.MainWindow); uint KEY_1 = VKConverter.getUINT(configuration.AppSettings.Settings["HOTKEY1"].Value); uint KEY_2 = VKConverter.getUINT(configuration.AppSettings.Settings["HOTKEY2"].Value); if (!RegisterHotKey(helper.Handle, HOTKEY_ID, KEY_1, KEY_2)) { // handle error } }