Esempio n. 1
0
        /// <summary>
        /// Simulates a modified keystroke where there is one modifier and multiple keys like CTRL-K-C where CTRL is the modifierKey and K and C are the keys.
        /// The flow is Modifier KeyDown, Keys Press in order, Modifier KeyUp.
        /// </summary>
        /// <param name="modifierKey">The modifier key</param>
        /// <param name="keyCodes">The list of keys to simulate</param>
        public void ModifiedKeyStroke(VirtualKeyCode modifierKey, IEnumerable <VirtualKeyCode> keyCodes)
        {
            var builder = new InputBuilder();

            builder.AddKeyDown(modifierKey);
            if (keyCodes != null)
            {
                keyCodes.ToList().ForEach(x => builder.AddKeyPress(x));
            }
            builder.AddKeyUp(modifierKey);

            SendSimulatedInput(builder.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// Simulates a modified keystroke where there are multiple modifiers and one key like CTRL-ALT-C where CTRL and ALT are the modifierKeys and C is the key.
        /// The flow is Modifiers KeyDown in order, Key Press, Modifiers KeyUp in reverse order.
        /// </summary>
        /// <param name="modifierKeyCodes">The list of modifier keys</param>
        /// <param name="keyCode">The key to simulate</param>
        public void ModifiedKeyStroke(IEnumerable <VirtualKeyCode> modifierKeyCodes, VirtualKeyCode keyCode)
        {
            var builder = new InputBuilder();

            if (modifierKeyCodes != null)
            {
                modifierKeyCodes.ToList().ForEach(x => builder.AddKeyDown(x));
            }
            builder.AddKeyPress(keyCode);
            if (modifierKeyCodes != null)
            {
                modifierKeyCodes.Reverse().ToList().ForEach(x => builder.AddKeyUp(x));
            }

            SendSimulatedInput(builder.ToArray());
        }