コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Keys saveKey   = (Keys)Enum.Parse(typeof(Keys), (savePositionComboBox.GetItemText(savePositionComboBox.SelectedItem)));
            Keys loadKey   = (Keys)Enum.Parse(typeof(Keys), (loadPositionComboBox.GetItemText(loadPositionComboBox.SelectedItem)));
            Keys noclipKey = (Keys)Enum.Parse(typeof(Keys), (noclipComboBox.GetItemText(noclipComboBox.SelectedItem)));

            addOrReplaceHotkey("saveKey", (int)saveKey);
            addOrReplaceHotkey("loadKey", (int)loadKey);
            addOrReplaceHotkey("noclipKey", (int)noclipKey);

            Properties.Settings.Default.SaveKey   = (int)saveKey;
            Properties.Settings.Default.LoadKey   = (int)loadKey;
            Properties.Settings.Default.NoclipKey = (int)noclipKey;
            Properties.Settings.Default.Save();
            KeyboardHook.UnInitialize();
            KeyboardHook.Initialize();
        }
コード例 #2
0
        public Form1()
        {
            addOrReplaceHotkey("saveKey", Properties.Settings.Default.SaveKey);
            addOrReplaceHotkey("loadKey", Properties.Settings.Default.LoadKey);
            addOrReplaceHotkey("noclipKey", Properties.Settings.Default.NoclipKey);


            InitializeComponent();
            KeyboardHook.Initialize();

            KeyboardHook.KeyPressed += hook_KeyPressed;
            var values = Enum.GetValues(typeof(Keys));

            for (int i = 0; i < values.Length; i++)
            {
                Keys key = (Keys)values.GetValue(i);
                if (key == Keys.Modifiers)
                {
                    continue;
                }
                savePositionComboBox.Items.Add(key.ToString());
                loadPositionComboBox.Items.Add(key.ToString());
                noclipComboBox.Items.Add(key.ToString());
                if (key == (Keys)getHotkey("saveKey"))
                {
                    savePositionComboBox.SelectedIndex = savePositionComboBox.Items.Count - 1;
                }
                if (key == (Keys)getHotkey("loadKey"))
                {
                    loadPositionComboBox.SelectedIndex = loadPositionComboBox.Items.Count - 1;
                }
                if (key == (Keys)getHotkey("noclipKey"))
                {
                    noclipComboBox.SelectedIndex = noclipComboBox.Items.Count - 1;
                }
            }
        }