예제 #1
0
 protected override bool ProcessKeyPreview(ref Message m)
 {
     if (ignore_message)
     {
         return(base.ProcessKeyPreview(ref m));
     }
     ignore_message = true;
     if (m.Msg == (int)KeyboardMessage.WM_KEYUP || m.Msg == (int)KeyboardMessage.WM_SYSKEYUP)
     {
         int  KeyCode  = (int)(((ulong)m.LParam & 0xFF0000) >> 16);
         bool extended = (int)((ulong)m.LParam & 0x01000000) != 0;
         if (KeyCode == LShift)
         {
             hook.action_button_keyboard = VirtualKeyCode.LSHIFT;
             ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.LSHIFT);
         }
         else if (KeyCode == RShift)
         {
             hook.action_button_keyboard = VirtualKeyCode.RSHIFT;
             ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.RSHIFT);
         }
         else if (KeyCode == Ctrl)
         {
             if (extended)
             {
                 hook.action_button_keyboard = VirtualKeyCode.RCONTROL;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.RCONTROL);
             }
             else
             {
                 hook.action_button_keyboard = VirtualKeyCode.LCONTROL;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.LCONTROL);
             }
         }
         else if (KeyCode == Alt)
         {
             if (extended)
             {
                 hook.action_button_keyboard = VirtualKeyCode.RMENU;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.RMENU);
             }
             else
             {
                 hook.action_button_keyboard = VirtualKeyCode.LMENU;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.LMENU);
             }
         }
         else
         {
             throw new NotImplementedException();
         }
         Saver.save_hook(hook.hook_target, hook.action_button_keyboard);
     }
     return(base.ProcessKeyPreview(ref m));
 }
예제 #2
0
 private void ScanKeyTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     e.SuppressKeyPress = true;
     FakeLabel.Focus();
     if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.ControlKey || e.KeyCode == Keys.Menu)
     {
         ignore_message = false;
     }
     else
     {
         hook.action_button_keyboard = (VirtualKeyCode)e.KeyValue;
         ScanKeyTextBox.Text         = vk_to_appropriate_string((VirtualKeyCode)e.KeyValue);
         ignore_message = true;
         Saver.save_hook(hook.hook_target, hook.action_button_keyboard);
     }
 }
예제 #3
0
 private void MouseradioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (hook.hook_target == Hook_target.Mouse)
     {
         hook.hook_target             = Hook_target.Keyboard;
         ScanKeyTextBox.Text          = vk_to_appropriate_string(hook.action_button_keyboard);
         MouseButtonsComboBox.Visible = false;
         ScanKeyTextBox.Visible       = true;
         Saver.save_hook(hook.hook_target, hook.action_button_keyboard);
     }
     else if (hook.hook_target == Hook_target.Keyboard)
     {
         hook.hook_target = Hook_target.Mouse;
         MouseButtonsComboBox.SelectedItem = vk_to_appropriate_string(hook.action_button_mouse);
         MouseButtonsComboBox.Visible      = true;
         ScanKeyTextBox.Visible            = false;
         Saver.save_hook(hook.hook_target, hook.action_button_mouse);
     }
 }
예제 #4
0
 private void MouseButtonsComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     hook.action_button_mouse = string_to_mouse_vk(MouseButtonsComboBox.SelectedItem.ToString());
     Saver.save_hook(hook.hook_target, hook.action_button_mouse);
 }