public FrmMain() { // // Required for Windows Form Designer support // InitializeComponent(); if (File.Exists(Application.StartupPath + "\\HotkeyValue.txt")) { StreamReader reader = File.OpenText(Application.StartupPath + "\\HotkeyValue.txt"); int val = -1; try { val = Int32.Parse(reader.ReadToEnd().Trim()); } catch { } if (val != -1) { Keys k = (Keys)val; bool success = FrmMain.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), ShortcutInput.Win32ModifiersFromKeys(k), ShortcutInput.CharCodeFromKeys(k)); if (success) { TxtKeyEnumValue.Text = val.ToString(); } else { MessageBox.Show("Could not register Hotkey - there is probably a conflict. ", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void FrmMain_Load(object sender, System.EventArgs e) { if (File.Exists(Application.StartupPath + "\\HotkeyValue.txt")) { StreamReader reader = File.OpenText(Application.StartupPath + "\\HotkeyValue.txt"); int val = -1; try { val = Int32.Parse(reader.ReadToEnd().Trim()); } catch {} if (val != -1) { Keys k = (Keys)val; bool success = FrmMain.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), ShortcutInput.Win32ModifiersFromKeys(k), ShortcutInput.CharCodeFromKeys(k)); if (success) { TxtKeyEnumValue.Text = val.ToString(); } else { MessageBox.Show("Could not register Hotkey - there is probably a conflict. ", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }