• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# VirtualKeyCode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: VirtualKey

        public VirtualKey(VirtualKeyCode virtualKey,
            string displayText,
            List<int> characters,
            bool isAffectedByCapsLock)
        {
            _virtualKey = virtualKey;
            _characters = characters;
            _isAffectedByCapsLock = isAffectedByCapsLock;
            _displayText = displayText;

            for (var x = 0; x < characters.Count; x++)
            {
                var character = default(char);
                var value = characters[x];
                if (value == Definitions.WCH_DEAD)
                {
                    character = ' ';
                }
                else if (value == Definitions.WCH_LGTR)
                {
                    character = ' ';
                }
                else if (value == Definitions.WCH_NONE)
                {
                    character = ' ';
                }
                else
                {
                    character = (char)value;
                }

                switch (x)
                {
                    case 0:
                        characterBase = character;
                        break;
                    case 1:
                        characterShift = character;
                        break;
                    case 2:
                        characterAltGraphics = character;
                        break;
                    case 3:
                        characterControl = character;
                        break;
                    case 4:
                        characterShiftControl = character;
                        break;
                    case 5:
                        characterShiftAltGraphics = character;
                        break;
                }
            }

            Display = GetDisplayValue(false, false);
        }
开发者ID:pauldotknopf,项目名称:WPFKeyboard,代码行数:56,代码来源:VirtualKey.cs


示例17: KeyPress

        /// <summary>
        /// Calls the Win32 SendInput method with a KeyDown and KeyUp message in the same input sequence in order to simulate a Key PRESS.
        /// </summary>
        /// <param name="keyCode">The <see cref="VirtualKeyCode"/> to press</param>
        public void KeyPress(VirtualKeyCode keyCode)
        {
            var inputList =
                new InputBuilder()
                    .AddKeyDown(keyCode)
                    .AddKeyUp(keyCode)
                    .ToArray();

            SendSimulatedInput(inputList);
        }
开发者ID:HaKDMoDz,项目名称:baro-corelibrary,代码行数:14,代码来源:KeyboardSimulator.cs


示例18: PressKey

        public static void PressKey(VirtualKeyCode S)
        {
            if (WindowHandle == null) {
                Console.WriteLine("Cant Send Keypress to Null Window");
                return;
            }

            InputSimulator.SimulateKeyPress(S);
            Console.WriteLine("Sent Key");
        }
开发者ID:fusspawn,项目名称:utils,代码行数:10,代码来源:InputManager.cs


示例19: SendMessage

        public void SendMessage(VirtualKeyCode key, VirtualKeyCode? modifier = null)
        {
            SetForegroundWindow(hWndLast);

            if (modifier != null)
            {
                InputSimulator.SimulateModifiedKeyStroke((VirtualKeyCode)modifier, key);
                return;
            }

            InputSimulator.SimulateKeyPress(key);
        }
开发者ID:GitHubAshur,项目名称:MtgoTouchUI,代码行数:12,代码来源:ProcessProvider.cs


示例20: KeyUp

 public void KeyUp(VirtualKeyCode virtualKeyCode)
 {
     try
     {
         Log.DebugFormat("Simulating key up: {0}", virtualKeyCode);
         inputSimulator.Keyboard.KeyUp(virtualKeyCode);
     }
     catch (Exception exception)
     {
         PublishError(this, exception);
     }
 }
开发者ID:nekulin,项目名称:OptiKey,代码行数:12,代码来源:PublishService.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VirtualKeys类代码示例发布时间:2022-05-24
下一篇:
C# VirtualKey类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap