private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Hotkey.UnregisterHotKey(Handle, 100); int key = comboBox1.SelectedIndex + 112; Hotkey.RegisterHotKey(Handle, 100, Hotkey.KeyModifiers.None, key); }
private void comboboxHotkey_SelectedIndexChanged(object sender, EventArgs e) { Hotkey.UnregisterHotKey(Handle, 100); int key = comboboxHotkey.SelectedIndex + 112; if (!Hotkey.RegisterHotKey(Handle, 100, Hotkey.KeyModifiers.None, key)) { MessageBox.Show("热键注册失败,请尝试关闭热键冲突的程序或更改热键", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); comboboxHotkey.SelectedIndex = -1; } }
private void btnCaptureWindowTitle_Click(object sender, EventArgs e) { Hotkey.UnregisterHotKey(Handle, 101); if (Hotkey.RegisterHotKey(Handle, 101, Hotkey.KeyModifiers.Shift, 113)) { btnCaptureWindowTitle.Text = "请转到对应的窗口按下Shift+F2..."; } else { MessageBox.Show("热键注册失败,请尝试关闭热键冲突的程序或手动输入窗口标题", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); } }