当前位置: 首页>>代码示例>>C#>>正文


C# VirtualKeyCode类代码示例

本文整理汇总了C#中VirtualKeyCode的典型用法代码示例。如果您正苦于以下问题:C# VirtualKeyCode类的具体用法?C# VirtualKeyCode怎么用?C# VirtualKeyCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VirtualKeyCode类属于命名空间,在下文中一共展示了VirtualKeyCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoKeyPress

 public static void DoKeyPress(VirtualKeyCode aKey)
 {
     InputSimulator.SimulateKeyDown(aKey);
     Thread.Sleep(200);
     InputSimulator.SimulateKeyUp(aKey);
     Thread.Sleep(200);
 }
开发者ID:plewt,项目名称:mu97bot,代码行数:7,代码来源:BotCommon.cs

示例2: AsyncHoldKey

        public static void AsyncHoldKey(VirtualKeyCode keycode)
        {
            if (InputSimulator.asyncHoldThread == null || !InputSimulator.asyncHoldThread.IsAlive)
            {
                InputSimulator.asyncHoldThread = new System.Threading.Thread( new System.Threading.ThreadStart(() =>
                {
                    while (InputSimulator.currentAsyncHoldKeys.Count > 0)
                    {
                        lock (InputSimulator.currentAsyncHoldKeys)
                        {
                            foreach (VirtualKeyCode iter in InputSimulator.currentAsyncHoldKeys)
                            {
                                Console.WriteLine(iter);
                                WindowsInput.InputSimulator.SimulateKeyDown(iter);
                            }
                        }
                        System.Threading.Thread.Sleep(10);
                    }
                }));
                InputSimulator.asyncHoldThread.IsBackground = true;
                InputSimulator.asyncHoldThread.Start();
            }

            currentAsyncHoldKeys.Add(keycode);
        }
开发者ID:Ranaakamarth,项目名称:SkyrimSpeechCommander,代码行数:25,代码来源:InputSimulator.cs

示例3: SimulateKeyPress

        public static void SimulateKeyPress(VirtualKeyCode keyCode)
        {
            var down = new Input();
            down.Type = (UInt32)InputType.KEYBOARD;
            down.Data.Keyboard = new KeybdInput
                                     {
                                         Vk = (UInt16) keyCode,
                                         Scan = 0,
                                         Flags = 0,
                                         Time = 0,
                                         ExtraInfo = IntPtr.Zero
                                     };

            var up = new Input();
            up.Type = (UInt32)InputType.KEYBOARD;
            up.Data.Keyboard = new KeybdInput
                                   {
                                       Vk = (UInt16) keyCode,
                                       Scan = 0,
                                       Flags = (UInt32) KeyboardFlag.KEYUP,
                                       Time = 0,
                                       ExtraInfo = IntPtr.Zero
                                   };

            var inputList = new Input[2];
            inputList[0] = down;
            inputList[1] = up;

            var numberOfSuccessfulSimulatedInputs = User32.SendInput(2, inputList, Marshal.SizeOf(typeof(Input)));
            if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format("The key press simulation for {0} was not successful.", keyCode));
        }
开发者ID:pingmeaschandru,项目名称:LiveMeeting,代码行数:31,代码来源:InputSimulator.cs

示例4: ModifierKey

 public ModifierKey(VirtualKeyCode key, params VirtualKeyCode[] additional)
 {
     _key = key;
     _additional = additional;
     if(_additional == null)
         _additional = new VirtualKeyCode[0];
 }
开发者ID:pauldotknopf,项目名称:WPFKeyboard,代码行数:7,代码来源:ModifierKey.cs

示例5: UpKey

 public static void UpKey(VirtualKeyCode keyCode)
 {
     if (Status.isKeyEnabled && InputSimulator.IsKeyDown(keyCode))
     {
         InputSimulator.SimulateKeyUp(keyCode);
     }
 }
开发者ID:cignoir,项目名称:KinecTh,代码行数:7,代码来源:GameAction.cs

示例6: GenerateCommand

        public static Command GenerateCommand(InstructionData instruction)
        {
            VirtualKeyCode[] keys=new VirtualKeyCode[Values.GetLength(0)];
            Values.CopyTo(keys, 0);

            switch (instruction.commandType)
            {
                case InstructionData_CommandType.JOYSTICKAXIS:
                    return new Command(new JoystickCommandData(0,(JoystickDataType)instruction.axis,(short)instruction.value));
                case InstructionData_CommandType.JOYSTICKBUTTON_PRESS:
                    return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_PRESS, 0, instruction.value));
                case InstructionData_CommandType.JOYSTICKBUTTON_HOLD:
                    return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_HOLD, 0, instruction.value));
                case InstructionData_CommandType.JOYSTICKBUTTON_RELEASE:
                    return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_RELEASE, 0, instruction.value));
                case InstructionData_CommandType.KEYBOARD_PRESS:
                    return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.PRESS, instruction.control, instruction.shift));
                case InstructionData_CommandType.KEYBOARD_HOLD:
                    return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.HOLD, instruction.control, instruction.shift));
                case InstructionData_CommandType.KEYBOARD_RELEASE:
                    return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.RELEASE, instruction.control, instruction.shift));
            }

            return null;
        }
开发者ID:Manu343726,项目名称:KinectStick,代码行数:25,代码来源:ProfileCompiler.cs

示例7: PressKey

 public static void PressKey(VirtualKeyCode keyCode)
 {
     if (Status.isKeyEnabled)
     {
         InputSimulator.SimulateKeyPress(keyCode);
     }
 }
开发者ID:cignoir,项目名称:KinecTh,代码行数:7,代码来源:GameAction.cs

示例8: KeyDown

 /// <summary>
 /// Эмулирует действие 'нажать и держать' над кнопкой.
 /// </summary>
 /// <param name="keyCode">
 /// Ключ целевой кнопки.
 /// </param>
 public IKeyboard KeyDown(VirtualKeyCode keyCode)
 {
     this.logger.Info("Key down '{0}'", keyCode.ToString());
     this.keyboardSimulator.KeyDown(keyCode);
     Thread.Sleep(250);
     return this;
 }
开发者ID:Zlabst,项目名称:Winium.Cruciatus,代码行数:13,代码来源:KeyboardSimulatorExt.cs

示例9: KeyboardCommandData

 public KeyboardCommandData(VirtualKeyCode key, KeyboardCommandType type, bool control = false, bool shift = false)
 {
     this.key = key;
     this.type = type;
     this.control = control;
     this.shift = shift;
 }
开发者ID:Manu343726,项目名称:KinectStick,代码行数:7,代码来源:Command.cs

示例10: Set

 public void Set(VirtualKeyCode key, KeyState keyState)
 {
     if(_modifierKeyState.ContainsKey(key))
         _modifierKeyState[key] = keyState;
     else
         _modifierKeyState.Add(key, keyState);
 }
开发者ID:archnaut,项目名称:sandbox,代码行数:7,代码来源:ChordSpecification.cs

示例11: DoBuff

 public static void DoBuff(VirtualKeyCode aKey, bool aSelf)
 {
     Point OldMousePos = MouseGetPos();;
     if (aSelf) CenterMouse();
     DoSkill(aKey);
     if (aSelf) MouseMove(OldMousePos);
 }
开发者ID:plewt,项目名称:mu97bot,代码行数:7,代码来源:BotCommon.cs

示例12: ShiftSensitiveKey

 public ShiftSensitiveKey(VirtualKeyCode keyCode, string normal, string modified, string displayText)
 {
     _keyCode = keyCode;
     _normal = normal;
     _modified = modified;
     _displayText = displayText;
     Display = !string.IsNullOrEmpty(_displayText) ? _displayText : _normal;
 }
开发者ID:pauldotknopf,项目名称:WPFKeyboard,代码行数:8,代码来源:ShiftSensitiveKey.cs

示例13: AddKeyInput

 private void AddKeyInput(VirtualKeyCode keyCode, bool isKeyUp)
 {
     INPUT input = new INPUT();
     input.Type = InputType.InputKeyboard;
     input.Data.Keyboard = new KEYBDINPUT();
     input.Data.Keyboard.wVk = keyCode;
     if (isKeyUp) input.Data.Keyboard.dwFlags = KeyboardEventFlags.KEYEVENTF_KEYUP;
     InputList.Add(input);
 }
开发者ID:Grifs99,项目名称:ShareX,代码行数:9,代码来源:InputManager.cs

示例14: AsyncReleaseKey

        public static void AsyncReleaseKey(VirtualKeyCode keycode)
        {
            lock (InputSimulator.currentAsyncHoldKeys)
            {
                InputSimulator.SimulateKeyUp(keycode);

                InputSimulator.currentAsyncHoldKeys.RemoveAll(key => key.Equals(keycode));
            }
        }
开发者ID:Ranaakamarth,项目名称:SkyrimSpeechCommander,代码行数:9,代码来源:InputSimulator.cs

示例15: MultiCharacterKey

 public MultiCharacterKey(VirtualKeyCode keyCode, IList<string> keyDisplays) :
     base(keyCode)
 {
     if (keyDisplays == null) throw new ArgumentNullException("keyDisplays");
     if (keyDisplays.Count <= 0)
         throw new ArgumentException("Please provide a list of one or more keyDisplays", "keyDisplays");
     KeyDisplays = keyDisplays;
     DisplayName = keyDisplays[0];
 }
开发者ID:Delta-Plan,项目名称:WpfKB.4.0,代码行数:9,代码来源:MultiCharacterKey.cs


注:本文中的VirtualKeyCode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。