예제 #1
0
        public bool setButtonDown(string key)
        {
            if (Enum.IsDefined(typeof(KeyboardKey), key.ToUpper()))
            {
                KeyboardKey theKeyCode = (KeyboardKey)Enum.Parse(typeof(KeyboardKey), key, true);
                report.keyDown(theKeyCode);
                return(true);
            }
            else if (Enum.IsDefined(typeof(KeyboardModifier), key.ToUpper()))
            {
                KeyboardModifier theKeyCode = (KeyboardModifier)Enum.Parse(typeof(KeyboardModifier), key, true);
                report.keyDown(theKeyCode);
                return(true);
            }
            else if (Enum.IsDefined(typeof(VirtualKeyCode), key.ToUpper()))
            {
                VirtualKeyCode theKeyCode = (VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), key, true);

                Enum vmultiKey = VmultiKeycodeAdapter.ConvertVirtualKeyCode(theKeyCode);

                if (vmultiKey == null)
                {
                    this.inputSimulator.Keyboard.KeyDown(theKeyCode);
                    return(true);
                }

                if (vmultiKey is KeyboardKey)
                {
                    KeyboardKey keyboardKey = (KeyboardKey)vmultiKey;
                    report.keyDown(keyboardKey);
                    return(true);
                }

                if (vmultiKey is KeyboardModifier)
                {
                    KeyboardModifier keyboardModifier = (KeyboardModifier)vmultiKey;
                    report.keyDown(keyboardModifier);
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        private static void keyboardTest(VMulti vmulti)
        {
            System.Diagnostics.Process.Start("notepad.exe");

            System.Threading.Thread.Sleep(3000);

            KeyboardReport report = new KeyboardReport();

            report.keyDown(KeyboardKey.H);
            vmulti.updateKeyboard(report);
            report.keyUp(KeyboardKey.H);
            report.keyDown(KeyboardKey.E);
            vmulti.updateKeyboard(report);
            report.keyUp(KeyboardKey.E);
            report.keyDown(KeyboardKey.L);
            vmulti.updateKeyboard(report);
            report.keyUp(KeyboardKey.L);
            vmulti.updateKeyboard(report);
            report.keyDown(KeyboardKey.L);
            vmulti.updateKeyboard(report);
            report.keyUp(KeyboardKey.L);
            report.keyDown(KeyboardKey.O);
            vmulti.updateKeyboard(report);
            report.keyUp(KeyboardKey.O);
            report.keyDown(KeyboardModifier.LShift);
            report.keyDown(KeyboardKey.Number1);
            vmulti.updateKeyboard(report);
            report.keyUp(KeyboardModifier.LShift);
            report.keyUp(KeyboardKey.Number1);
            vmulti.updateKeyboard(report);

            System.Threading.Thread.Sleep(4000);
            report.keyDown(KeyboardModifier.LWin);
            report.keyDown(KeyboardKey.D);
            vmulti.updateKeyboard(report);
            report.keyUp(KeyboardModifier.LWin);
            report.keyUp(KeyboardKey.D);
            vmulti.updateKeyboard(report);
        }