Exemplo n.º 1
0
        /// <summary>
        /// Initializes the KeyboardController, blocks user input, and sets
        /// the focus on the specified control.
        /// </summary>
        /// <param name="control">The ControlTester to use the keyboard on.</param>
        public void UseOn(ReflectionTester control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            Control c = control.TheObject as Control;

            FormsAssert.IsTrue(c != null, "Keyboard control requires tester of Control");
            sendKeys = sendKeysFactory.Create(c.Handle);

            keyboardControl = new KeyboardControl(control);

            if (!restoreUserInput)
            {
                //if this next line returns false, I used to throw an exception...
                User32.BlockInput(true);
                restoreUserInput = true;
            }
        }
        /// <summary>
        /// Initializes the KeyboardController, blocks user input, and sets
        /// the focus on the specified control.
        /// </summary>
        /// <param name="control">The ControlTester to use the keyboard on.</param>
        public void UseOn(ReflectionTester control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            Control c = control.TheObject as Control;
            FormsAssert.IsTrue(c != null, "Keyboard control requires tester of Control");
            sendKeys = sendKeysFactory.Create(c.Handle);

            keyboardControl = new KeyboardControl(control);

            if (!restoreUserInput)
            {
                //if this next line returns false, I used to throw an exception...
                Win32.BlockInput(true);
                restoreUserInput = true;
            }
        }