示例#1
0
        public void SimulateKeyUp()
        {
            if (!_pressed)
            {
                return;
            }

            if (!FakeToggle)
            {
                _pressed = false;
                if (VirtualKey != Keys.NoName)
                {
                    InputSimulator.SimulateKeyUp((VirtualKeyCode)VirtualKey);
                    VirtualKeyUp?.Invoke(this, (VirtualKeyCode)VirtualKey);
                }
                else if (IsAltGrPressed)
                {
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.RMENU);
                    InputSimulator.SimulateKeyUp(VirtualKeyCode.LCONTROL);
                }
                else
                {
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.LCONTROL);
                    InputSimulator.SimulateKeyDown(VirtualKeyCode.RMENU);
                }
            }
        }
示例#2
0
 public void SimulateKeyDown()
 {
     if (VirtualKey == Keys.LShiftKey)
     {
         Console.WriteLine("f1");
     }
     if (!FakeToggle)
     {
         if (VirtualKey != Keys.NoName)
         {
             InputSimulator.SimulateKeyDown((VirtualKeyCode)VirtualKey);
             VirtualKeyDown?.Invoke(this, (VirtualKeyCode)VirtualKey);
         }
         else
         {
             InputSimulator.SimulateKeyDown(VirtualKeyCode.LCONTROL);
             InputSimulator.SimulateKeyDown(VirtualKeyCode.RMENU);
         }
         _pressed = true;
     }
     else
     {
         if (!Toggled)
         {
             Toggled          = true;
             ButtonBackground = new SolidColorBrush(Color.FromArgb(120, 255, 255, 255));
             if (VirtualKey != Keys.NoName)
             {
                 InputSimulator.SimulateKeyDown((VirtualKeyCode)VirtualKey);
                 VirtualKeyDown?.Invoke(this, (VirtualKeyCode)VirtualKey);
             }
             else
             {
                 InputSimulator.SimulateKeyDown(VirtualKeyCode.LCONTROL);
                 InputSimulator.SimulateKeyDown(VirtualKeyCode.RMENU);
             }
         }
         else
         {
             Toggled          = false;
             ButtonBackground = Brushes.Transparent;
             if (VirtualKey != Keys.NoName)
             {
                 InputSimulator.SimulateKeyUp((VirtualKeyCode)VirtualKey);
                 VirtualKeyUp?.Invoke(this, (VirtualKeyCode)VirtualKey);
             }
             else
             {
                 InputSimulator.SimulateKeyUp(VirtualKeyCode.RMENU);
                 InputSimulator.SimulateKeyUp(VirtualKeyCode.LCONTROL);
             }
         }
     }
 }